Skip to content

Pipeline quota page: Show projects with most CI minutes

What does this MR do and why?

By sorting the projects with most CI minutes to the top of the list, we follow a more useful sorting logic for a "quota" page, than the project's IDs. Additionally, this may help in finding possibly inefficient CI scripts.

Mainly resolves Usage Quotas - support for sorting projects by ... (#195487 - closed), which necessitated:

  • filtering out projects with 0 minutes
  • switching the groups' & profiles' usage_quotas_controller.rb to a different data source
  • updating & adding relevant tests
  • removing the then obsolete Project#ci_minutes_used method & spec

And included:

Was prompted by working on an internal ticket.

Screenshots or screen recordings

How to set up and validate locally

  1. Create a group with 2 projects that have simple CI jobs with sleep 60 and sleep 90
  2. Configure the group's CI quota
  3. Reload the group's /usage_quotas#pipelines-quota-tab page while triggering a few pipelines in one or the other project.
  4. Retry with another project (and/or one in a subgroup) that have 0 minutes initially, and run a few jobs then.

GDK's Rails console can be used instead of waiting for Runners & jobs:

Ci::Minutes::ProjectMonthlyUsage.increase_usage(
  Ci::Minutes::ProjectMonthlyUsage.where(date: (Time.current.utc).beginning_of_month).safe_find_or_create_by(
    project_id: ),
  amount_used: ,
  shared_runners_duration: 
)

See also screenshot in #358382 (comment 926054589)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

> 3. … existing automated tests do not cover the above functionality …

Since no test broke, I guess we don't test for either sorting order yet.

  1. … considered the impact of this change on the frontend, backend, and database …

See !83680 (comment 896959160).

Edited by Katrin Leinweber

Merge request reports