Skip to content

Expose new monthIso8601 GraphQL option to fix CI minutes usage sorting

What does this MR do and why?

This MR fixes the ordering for the months in the CI minutes quota chart. The GraphQL query did not have enough information to perform an effective ordering (only contained full month names of 'January', 'December', etc.), which made ordering on the frontend tricky. I've added in monthIso8601 as a GraphQL option to NamespaceMonthlyUsageType and am using it on the frontend for much easier ordering. Because the year context is then available on the frontend, I've also included it in the X axis on the chart, as having just the month names seemed a bit confusing.

Screenshots or screen recordings

Screen_Shot_2022-01-12_at_08.55.11

How to set up and validate locally

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

  1. Run the following in a rails console:
    user = User.find(1) # This is the root user of the GDK
    [[2021, 4, 1], [2021, 6, 1], [2021, 8, 1], [2021, 10, 1], [2021, 12, 1], [2022, 1, 1]].each do |n|
      begin
        namespace_usage = Ci::Minutes::NamespaceMonthlyUsage.new(namespace_id: user.namespace.id, date: Date.new(*n), amount_used: 70)
        namespace_usage.save
      rescue ActiveRecord::RecordNotUnique
      end
    end
  2. Visit the root user's usage quota page: http://localhost:3000/-/profile/usage_quotas
  3. Confirm CI minutes graph is sorted correctly and rendering months correctly.

MR acceptance checklist

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

Related to #349959 (closed)

Edited by David Barr

Merge request reports