Fix JobAnalytics deduplicated finder query and gate behind feature flag

What does this MR do and why?

  • Fixes Ci::JobAnalytics::QueryBuilder to call final_query on FinishedBuildsDeduplicatedFinder instead of query_builder, which was producing queries without the required inner subquery structure. Also makes final_query a public method so it can be called from outside the finder.
  • To safely roll this fix out, the use of the deduplicated finder is now gated behind a gitlab_com_derisk feature flag (:use_job_analytics_deduplicated_finder) scoped to project, allowing incremental per-project rollout during the ClickHouse backfill migration.

Changes

  • Call final_query on FinishedBuildsDeduplicatedFinder to construct the correct query with FROM inner subquery
  • Move final_query from private to public in FinishedBuildsDeduplicatedFinder
  • Add :use_job_analytics_deduplicated_finder feature flag (gitlab_com_derisk, project-scoped)
  • Add spec coverage for the feature flag gating and deduplicated finder SQL generation

References

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading