Skip to content

Implement General /api/where/problem-reports Search Endpoint #460

@AhmedAlian7

Description

@AhmedAlian7

Description

This issue implements the general search and list endpoint for problem reports (/api/where/problem-reports).
follow-up for #449

Context

Currently, there is no centralized way for transit operators to query reports across the entire system without knowing specific IDs.


Proposed Changes

1. Database Layer (SQLC)

Re-introduce and expand the filtered queries in gtfsdb/query.sql. After updating the SQL, run make models to generate the Go code.

  • Recent Reports: Implement GetRecentProblemReportsTrip and GetRecentProblemReportsStop with support for LIMIT and OFFSET.
  • Filtering: * GetProblemReportsTripByDateRange / GetProblemReportsStopByDateRange
    • GetProblemReportsTripByCode / GetProblemReportsStopByCode

2. API Handler

Create a new handler file at internal/restapi/problem_reports_handler.go.

  • Logic: Implement problemReportsHandler to parse the following query parameters:
    • startDate, endDate (ISO 8601)
    • code (Error/Category code)
    • offset, limit (Pagination)
  • Aggregation: The handler should query both Trip and Stop reports, combine the results into a unified list, and sort them (typically by timestamp descending).

3. Routing

Register the new route in routes.go:

  • Endpoint: GET /api/where/problem-reports
  • Middleware: Ensure standard API key validation is applied. Note that this endpoint does not require a specific ID in the path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions