Skip to content

refactor: replace GetTrips() full-table load with targeted DB query#850

Merged
Ahmedhossamdev merged 2 commits intomainfrom
refactor/migrate-get-trips-to-db
Apr 11, 2026
Merged

refactor: replace GetTrips() full-table load with targeted DB query#850
Ahmedhossamdev merged 2 commits intomainfrom
refactor/migrate-get-trips-to-db

Conversation

@Ahmedhossamdev
Copy link
Copy Markdown
Member

Fixes: #826
Part of: #820

Summary

  • Removes in-memory GetTrips() (which loaded all trips from gtfsData.Trips) and replaces it with GetTrips(ctx, limit) backed by a new ListTripsWithLimit SQL query
  • Adds ListTripsWithLimit to query.sql — uses LIMIT ? to avoid full-table scans, especially important for large merged feeds
  • Updates all test call sites to use mustGetTrips(t, api) helper (limit 100) and maps flat gtfsdb.Trip fields (RouteID, ServiceID, TripHeadsign, etc.) replacing the old nested gtfs.ScheduledTrip fields (Route.Id, Service.Id, Headsign, etc.)
  • Fixes pre-existing errcheck lint issue in stops_rtree.go

@github-actions
Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 3.1 ms
Error rate 0.00%
Total requests 344
Req/sec 11.3

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

if err != nil {
return nil, err
}
defer rows.Close()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where'd you see the error lint for this? was it in presubmits or somewhere else?

Copy link
Copy Markdown
Member Author

@Ahmedhossamdev Ahmedhossamdev Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run make lint
image

@Ahmedhossamdev Ahmedhossamdev force-pushed the refactor/migrate-get-trips-to-db branch from 238bd7c to 3ddad09 Compare April 11, 2026 02:29
@github-actions
Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 3.6 ms
Error rate 0.00%
Total requests 333
Req/sec 10.9

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@Ahmedhossamdev Ahmedhossamdev merged commit 7abc9d8 into main Apr 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace GetTrips() full-table load with targeted per-handler queries

2 participants