Update CiJobAnalytics API query layer to query only the latest version of records
Summary
Update all queries in the API layer that read from the ci_finished_builds ClickHouse table to properly use the version and deleted columns using FINAL and deleted = 0. This ensures that only the latest version of each record is returned (when deduplication happens in the background merge).
Context
The ci_finished_builds ClickHouse table has been converted to use ReplacingMergeTree(version, deleted) to support data deduplication and backfilling. However, the API query layer has not been updated to account for these versioning columns, which means queries may return stale or duplicate records.
Related
- Blocks: #585179 - Backfill ci_finished_builds with stage_name and other required fields
- Related: #580441 (closed) - Sync stage_name to ClickHouse for job analytics grouping
- Related: !217569 (merged), Alter `ci_finished_builds` CH table engine (!217789 - merged)
Edited by 🤖 GitLab Bot 🤖