Skip to content

Update subscriptionUsage query

What does this MR do and why?

Update subscriptionUsage query

References

This work is divided in 3 main issues:

PoC:

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. These fields rely on CustomersDot code that isn't merged just yet, so the easiest way to test this is to mock the CDot response:
Mocked response patch
diff --git a/ee/lib/gitlab/subscription_portal/subscription_usage_client.rb b/ee/lib/gitlab/subscription_portal/subscription_usage_client.rb
index dd09383d3240..63588fe004e1 100644
--- a/ee/lib/gitlab/subscription_portal/subscription_usage_client.rb
+++ b/ee/lib/gitlab/subscription_portal/subscription_usage_client.rb
@@ -180,6 +180,10 @@ def initialize(
       end

       def get_metadata
+        return {
+          success: true,
+          subscriptionUsage: { lastEventTransactionAt: 2.hours.ago }
+        }
         response = execute_graphql_query(
           query: GET_METADATA_QUERY,
           variables: default_variables
@@ -197,6 +201,13 @@ def get_metadata
       strong_memoize_attr :get_metadata

       def get_one_time_credits
+        return {
+          success: true,
+          oneTimeCredits: {
+            totalCredits: 543.21,
+            creditsUsed: 123.45
+          }
+        }
         response = execute_graphql_query(
           query: GET_ONE_TIME_CREDITS_QUERY,
           variables: default_variables.merge(startDate: start_date, endDate: end_date)
@@ -285,6 +296,10 @@ def get_usage_for_user_ids(user_ids)
       end

       def get_users_usage_stats
+        return {
+          success: true,
+          usersUsage: { creditsUsed: 111.22 }
+        }
         response = execute_graphql_query(
           query: GET_USERS_USAGE_STATS_QUERY,
           variables: default_variables.merge(startDate: start_date, endDate: end_date)
  1. Then open GraphQL explorer and execute this query (https://gdk.test:3443/-/graphql-explorer)
GraphQL query
query getSubscriptionUsage($namespacePath: ID) {
  subscriptionUsage(namespacePath: $namespacePath) {
    lastEventTransactionAt
    oneTimeCredits {
      totalCredits
      creditsUsed
    }
    usersUsage {
      creditsUsed
    }
  }
}

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 Sheldon Led

Merge request reports

Loading