Draft: use distance-precompute in external-metrics

This MR was taken over by Claude code.

Add distance rule precomputation results to the GraphQL API

Integrates the output of distance-precompute into the squid database and exposes it via PostGraphile.

Data model

  • DistancePrecompute — singleton (id = "current"), updated at each run. Holds computedOn: Block, memberCount, refereesCount, minCertsForReferee.
  • DistanceResult — one row per identity (id = identity.id). Holds accessibleReferees and a FK to DistancePrecompute. Replaces the previous row on each new computation.
  • Identity.latestDistanceResult — derived from DistanceResult.identity (one-to-one, no extra column on identity).

Services

external-metrics (new) — single container replacing the former distance-precompute + distance-importer split:

  • Runs distance-precompute against the configured RPC endpoint
  • On success, immediately calls node lib/distance_importer.js (one-shot import into PostgreSQL)
  • Sleeps INTERVAL seconds and repeats
  • Published as duniter/squid-external-metrics-{network}:{version}

GraphQL

The schema-aware-inflector plugin is extended to handle one-to-one @derivedFrom relations (via singleRelationByKeysBackwards), so identity.latestDistanceResult is correctly exposed rather than the auto-generated distanceResult name.

CI

Added build:external-metrics job following the same pattern as existing build jobs. The distance-precompute binary is pulled from duniter/distance-precompute-{network}:{version} via a multi-stage COPY --from.

Merge request reports

Loading