Fix months dropdown for the usage quotas feature

What does this MR do and why?

Fixes missing months on the CI/CD minutes usage dropdowns

#388717 (closed)

Screenshots or screen recordings

Before After
Screenshot_2023-02-16_at_13.38.15 Screenshot_2023-02-16_at_13.38.34

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Start a rails console session, bundle exec rails console or bundle exec rails c
  2. Create a couple of CI/CD minutes usage entries, one for December of 2022 and one for January of 2023
user = User.find(1)
project = Project.find(23) # Change this ID to whatever project ID you wish to use

monthly_usage = Ci::Minutes::ProjectMonthlyUsage.new(project_id: project.id, date: Date.new(2022, 12, 01), amount_used: 70, shared_runners_duration: 100)
monthly_usage.save
namespace_usage = Ci::Minutes::NamespaceMonthlyUsage.new(namespace_id: user.namespace.id, date: Date.new(2022, 12, 01), amount_used: 70, shared_runners_duration: 100)
namespace_usage.save

monthly_usage = Ci::Minutes::ProjectMonthlyUsage.new(project_id: project.id, date: Date.new(2023, 01, 01), amount_used: 120, shared_runners_duration: 150)
monthly_usage.save
namespace_usage = Ci::Minutes::NamespaceMonthlyUsage.new(namespace_id: user.namespace.id, date: Date.new(2023, 01, 01), amount_used: 120, shared_runners_duration: 150)
namespace_usage.save
  1. Go to User preferences -> Usage Quotas and play with the Usage by Project dropdowns and they should display accordingly

MR acceptance checklist

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

Edited by Jose Ivan Vargas

Merge request reports

Loading