• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rm-hull / fuel-prices-api / 23564552979

25 Mar 2026 09:16PM UTC coverage: 27.025% (-1.6%) from 28.645%
23564552979

push

github

web-flow
feat: add price history endpoint and error handling (#39)

* feat: add price history endpoint and error handling

- Added `/v1/fuel-prices/history/:node_id/:fuel_type` endpoint.
- Implemented `PriceHistory` in the repository layer using a new SQL
  query.
- Added global `NoRoute` and `NoMethod` handlers to improve API
  consistency.

```mermaid
sequenceDiagram
    participant C as Client
    participant A as API Server
    participant R as Repository
    participant DB as SQLite

    C->>A: GET /history/:node_id/:fuel_type
    A->>R: PriceHistory(node_id, fuel_type)
    R->>DB: Query price_history.sql
    DB-->>R: Returns price rows
    R-->>A: Returns []FuelPrice
    A-->>C: Returns PriceHistoryResponse (JSON)
```

* Update internal/sql/price_history.sql

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* feat: add validation for fuel types in route

- Add `FuelTypes` method to `FuelPricesRepository` with caching.
- Validate requested `fuel_type` against database records before
  querying price history.

```mermaid
sequenceDiagram
    participant User
    participant Router
    participant Repo
    participant DB

    User->>Router: GET /history/:node_id/:fuel_type
    Router->>Repo: FuelTypes()
    Repo->>DB: SELECT DISTINCT fuel_type...
    Repo-->>Router: map[string]struct{}
    alt fuel type exists
        Router->>Repo: PriceHistory(node_id, fuel_type)
        Router-->>User: 200 OK
    else fuel type missing
        Router-->>User: 400 Bad Request
    end
```

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

0 of 81 new or added lines in 3 files covered. (0.0%)

387 of 1432 relevant lines covered (27.03%)

0.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/api_server.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc