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
- Create a group with 2 projects that have simple CI jobs with
sleep 60
andsleep 90
- Configure the group's CI quota
- Reload the group's
/usage_quotas#pipelines-quota-tab
page while triggering a few pipelines in one or the other project. - 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.
-
I have evaluated the MR acceptance checklist for this MR.
> 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.
- … considered the impact of this change on the frontend, backend, and database …