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

rm-hull / fuel-prices-api / 22929444349
46%

Build:
DEFAULT BRANCH: main
Ran 10 Mar 2026 11:47PM UTC
Jobs 1
Files 20
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

10 Mar 2026 11:46PM UTC coverage: 26.814% (+9.2%) from 17.598%
22929444349

push

github

web-flow
feat: add fuel price distribution metrics (#31)

* feat: add fuel price distribution metrics

- Add `fuel_price_distribution_stats` SQL view to calculate price
buckets.
- Expose price distribution data via `SnapshotStatistics` model.
- Add Prometheus gauge metric `fuel_prices_govuk_api_price_distribution`
  to track sample counts per price bucket.
- Include database migration to support new distribution analytics.

* feat: refactor distribution data into buckets

Migrate `Distribution` model to use a `map[int]int` for buckets instead
of individual records per price point. This reduces payload size and
improves query grouping logic when exporting fuel price statistics.

```mermaid
graph LR
    subgraph OldStructure
    A[Row 1: Bucket 10]
    B[Row 2: Bucket 20]
    end

    subgraph NewStructure
    C[Distribution { Buckets: {10: X, 20: Y} }]
    end

    A --> C
    B --> C
```

* feat: separate distribution and snapshot stats

Split statistics logic and endpoints to allow independent querying of
snapshot and distribution data.

- Updated `FuelPricesRepository` interfaces and implementation.
- Refactored `metrics.fuelPricesGaugeCollector` to handle separate data
  fetchers.
- Moved endpoints to `/v1/fuel-prices/stats/snapshot` and
  `/v1/fuel-prices/stats/distribution`.

```mermaid
sequenceDiagram
    participant API as API Server
    participant Repo as Repository
    participant DB as SQLite DB

    API->>Repo: DistributionStats()
    Repo->>Repo: Check Cache
    Repo->>DB: Query Distribution
    DB-->>Repo: Result
    Repo-->>API: DistributionStatistics
```

* refactor: split metrics collectors into dedicated files

Separated `Snapshot` and `Distribution` metric collectors into their own
files to improve maintainability and decouple their registration logic.

```mermaid
graph TD
    subgraph metrics [metrics package]
        A[bootstrap.go] --> B[snapshot_metrics.go]
        A --> C[distribution_metrics.go]
    end
```

* chore: remove legacy snap... (continued)

126 of 162 new or added lines in 6 files covered. (77.78%)

1 existing line in 1 file now uncovered.

351 of 1309 relevant lines covered (26.81%)

0.29 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
0.0
0.0% cmd/api_server.go
2
0.0
0.0% cmd/bootstrap.go
3
89.29
internal/metrics/distribution_metrics.go
3
92.11
internal/metrics/snapshot_metrics.go
12
69.5
15.3% internal/repository.go
14
0.0
0.0% internal/routes/stats.go

Uncovered Existing Lines

Lines Coverage ∆ File
1
69.5
15.3% internal/repository.go
Jobs
ID Job ID Ran Files Coverage
1 22929444349.1 10 Mar 2026 11:47PM UTC 20
26.81
GitHub Action Run
Source Files on build 22929444349
  • Tree
  • List 20
  • Changed 4
  • Source Changed 0
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 9307be63 on github
  • Prev Build on main (#22928444781)
  • Next Build on main (#22929805669)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc