Clickhouse model and finder for ci_finished_builds

What does this MR do and why?

  • As a first iteration of the API, committing clickhouse model for ci_finished_builds clickhouse table
  • The finder has methods to construct the queries we need in the API and executes the query to get the results
  • Constructed the query methods by keeping the design (data we need in the UI) in mind

Design:

image

References

Add jobAnalytics GraphQL API to fetch data on o... (#541703 - closed)

Screenshots or screen recordings

image

How to set up and validate locally

Usage:

query = ClickHouse::Finders::Ci::FinishedBuildsFinder.new.select([:stage_id, :name]).mean_duration_in_seconds.p95_duration_in_seconds.rate_of_status.order_by(:mean_duration_in_seconds)

results = query.execute

puts results # might print huge data; instead, use `results.size` to verify

query.to_sql

=> "SELECT `ci_finished_builds`.`stage_id`, `ci_finished_builds`.`name`, avg(`ci_finished_builds`.`duration`) / 1000.0 AS mean_duration_in_seconds, quantile(0.95)(`ci_finished_builds`.`duration`) / 1000.0 AS p95_duration_in_seconds, countIf(`ci_finished_builds`.`status` = 'success') / count() * 100 AS rate_of_success FROM `ci_finished_builds` GROUP BY stage_id, name ORDER BY mean_duration_in_seconds ASC"

Coverage

image

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.

Edited by Pedro Pombeiro

Merge request reports

Loading