Skip to content

Commit

Permalink
add indexes for trips
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerrr committed Jul 30, 2024
1 parent 63f13e5 commit 19c3c6b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 46 deletions.
88 changes: 46 additions & 42 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "backend"
version = "0.4.7"
version = "0.4.8"
edition = "2021"


[dependencies]
axum = "0.7.5"
chrono = { version = "0.4.38", features = ["serde"] }
Expand Down
15 changes: 15 additions & 0 deletions backend/migrations/20240730230831_trip_indexes.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DROP INDEX IF EXISTS idx_trips_id;

DROP INDEX IF EXISTS idx_positions_trip_id;

DROP INDEX IF EXISTS idx_stop_times_trip_id;

DROP INDEX IF EXISTS idx_stop_times_arrival;

DROP INDEX IF EXISTS idx_bus_trips_id;

DROP INDEX IF EXISTS idx_bus_positions_trip_id;

DROP INDEX IF EXISTS idx_bus_stop_times_trip_id;

DROP INDEX IF EXISTS idx_bus_stop_times_arrival;
17 changes: 17 additions & 0 deletions backend/migrations/20240730230831_trip_indexes.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Train stuff
CREATE INDEX idx_trips_id ON trips(id);

CREATE INDEX idx_positions_trip_id ON positions(trip_id);

CREATE INDEX idx_stop_times_trip_id ON stop_times(trip_id);

CREATE INDEX idx_stop_times_arrival ON stop_times(arrival);

-- Bus stuff
CREATE INDEX idx_bus_trips_id ON bus_trips(id);

CREATE INDEX idx_bus_positions_trip_id ON bus_positions(vehicle_id);

CREATE INDEX idx_bus_stop_times_trip_id ON bus_stop_times(trip_id);

CREATE INDEX idx_bus_stop_times_arrival ON bus_stop_times(arrival);
2 changes: 0 additions & 2 deletions backend/src/routes/bus/trips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ WHERE
Ok(Json(trips))
}

//

#[derive(FromRow, Serialize)]
pub struct BusTripData {
id: Uuid,
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trainstatus",
"version": "0.4.7",
"version": "0.4.8",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down

0 comments on commit 19c3c6b

Please sign in to comment.