Skip to content

Split AI impact dashboard table into multiple panels

Alex Pennells requested to merge 461748-split-ai-impact into master

What does this MR do and why?

Splits the metric table into a 2 separate panels, one for AI metrics and one for Lifecycle metrics.

Doing so required the addition of an excludeMetrics filter on the ai_impact_table visualization. Excluded metrics are hidden from the rendered table, and if all metrics for a metric group (DORA/flow/vulnerability/AI metric groups) are hidden, then the API request will be skipped.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2024-09-24_at_12.04.13_PM Screenshot_2024-09-24_at_11.59.29_AM

How to set up and validate locally

Access the AI Impact analytics dashboard

  1. Ensure that you are using GitLab Ultimate
  2. Configure your GDK to use ClickHouse
# enable clickhouse
Feature.enable(:clickhouse_data_collection)
Feature.enable(:event_sync_worker_for_click_house)

# enable the worker to sync code suggestions events to clickhouse
Feature.enable(:code_suggestion_events_in_click_house)
  1. Enable this patch to apply the Duo AddOn
diff --git a/ee/app/models/ee/user.rb b/ee/app/models/ee/user.rb
index 3daed56e4068..171f4103c63a 100644
--- a/ee/app/models/ee/user.rb
+++ b/ee/app/models/ee/user.rb
@@ -478,6 +478,7 @@ def using_gitlab_com_seat?(namespace)
     end

     def assigned_to_duo_enterprise?(container)
+      return true
       namespace = ::Gitlab::Saas.feature_available?(:gitlab_duo_saas_only) ? container.root_ancestor : nil

       GitlabSubscriptions::AddOnPurchase
  1. Create a new group
  2. Navigate to the Analytics dashboard page for the new group (ex. http://gdk.test:3000/groups/flightjs/-/analytics/dashboards)
  3. Select the AI impact analytics dashboard

Add mock dashboard data (optional)

  1. Determine the ID of a project in your test group
  2. Enter the rails console: rails c
  3. Create reference to your test project: project = Project.find(ID)
  4. Run any of the necessary data mocks below:
DORA metrics
[
  [1.month.ago, 5, 1, 5, 2],
  [2.month.ago, 10, 3, 3, 3],
  [3.month.ago, 8, 5, 7, 1],
  [4.month.ago, 5, 1, 5, 2],
  [5.month.ago, 10, 3, 3, 3],
  [6.month.ago, 8, 5, 7, 1]
].each do |date, deploys, lead_time_for_changes, time_to_restore_service, incidents_count|
  Dora::DailyMetrics.create!(
    deployment_frequency: deploys,
    lead_time_for_changes_in_seconds: lead_time_for_changes * 1.day.to_i,
    time_to_restore_service_in_seconds: time_to_restore_service * 1.day.to_i,
    incidents_count: incidents_count,
    environment: project.default_environment,
    date: date
  )
end
Flow metrics
[
  [1.month.ago.beginning_of_month + 2.days, 2, 10],
  [2.month.ago.beginning_of_month + 2.days, 4, 20],
  [3.month.ago.beginning_of_month + 2.days, 3, 15],
  [4.month.ago.beginning_of_month + 2.days, 2, 10],
  [5.month.ago.beginning_of_month + 2.days, 4, 20],
  [6.month.ago.beginning_of_month + 2.days, 3, 15]
].each do |created_at, lead_time, count|
  count.times do
    Issue.create!(
      project: project,
      author: project.users.first,
      title: "create_mock_flow_metrics #{SecureRandom.hex}",
      created_at: created_at,
      closed_at: created_at + lead_time.days
    ).metrics.update!(first_mentioned_in_commit_at: created_at + 1.day)
  end
end

Analytics::CycleAnalytics::DataLoaderService.new(group: project.group, model: Issue).execute
Vulnerabilities metrics
[
  [1.month.ago.end_of_month, 3, 2],
  [2.month.ago.end_of_month, 5, 4],
  [3.month.ago.end_of_month, 2, 3],
  [4.month.ago.end_of_month, 3, 2],
  [5.month.ago.end_of_month, 5, 4],
  [6.month.ago.end_of_month, 2, 3]
].each do |date, critical, high|
  Vulnerabilities::HistoricalStatistic.create!(
    date: date,
    high: high,
    critical: critical,
    total: critical + high,
    letter_grade: 'a',
    project: project
  )
end

Related to #461748 (closed)

Edited by Alex Pennells

Merge request reports

Loading