Skip to content

Extract value stream controller functionality

What does this MR do and why?

This MR extracts the Value Streams controller functionality to a module so it can be reused on the project level. The MR contains quite a bit of code, however, most of the things are just rearranging code (no functional change).

Summary:

  • Move the index action from FOSS Projects::Analytics::CycleAnalytics::ValueStreamsController to Analytics::CycleAnalytics::ValueStreamActions module.
  • Move all actions from Groups::Analytics::CycleAnalytics::ValueStreamsController to EE::Analytics::CycleAnalytics::ValueStreamActions
  • Remove the obsoleted (we use requests specs now) controller test: ee/spec/controllers/groups/analytics/cycle_analytics/value_streams_controller_spec.rb
  • Implement a shared example that can be used to test both EE Project level and EE Group level controllers.
  • Introduce a convenient method allowed? to authorize access to Group and Project level VSA.
  • The edit and new HAML files were left empty intentionally. We'll integrate the views with VUE FE in the next MR.

What's new

  • Shared examples: ee/spec/support/shared_examples/controllers/analytics/cycle_analytics/value_stream_shared_examples.rb
  • allowed? method: ee/lib/gitlab/analytics/cycle_analytics.rb

How to set up and validate locally

Verify that the FOSS version of project-level VSA works

  1. Seed VSA: SEED_CYCLE_ANALYTICS=true SEED_VSA=true FILTER=cycle_analytics rake db:seed_fu
  2. Go to the printed-out project path
  3. Open the network tab in your browser
  4. Navigate to Analytics -> Value Stream
  5. All network requests should succeed (no 500 errors) and the page should show some number.

Verify that the FOSS version works with license

This is a temporary "state". For paid users, we still show the FOSS VSA because the FE changes are not ready yet.

  1. License your GL: ultimate or premium
  2. Repeat the same steps as in the previous section.

Verify that the licensed functionality also works

Note: this is not user-facing yet, so we need to do some manual work:

  1. Start rails c
  2. Find the project and create a stage
project = Project.find_by_full_path("vsmg-1674200626/vsmp-1674200626") # use your generated project path
value_stream = Analytics::CycleAnalytics::ValueStream.create!(namespace: project.project_namespace, name: 'my value stream')
stage = Analytics::CycleAnalytics::Stage.create(name: 'Test Stage', namespace: project.project_namespace, value_stream: value_stream, start_event_identifier: 'merge_request_created', end_event_identifier: 'merge_request_merged')
puts "value stream id: #{value_stream.id}"
puts "stage id: #{stage.id}"
puts "constructed URLs:"

puts Rails.application.routes.url_helpers.namespace_project_analytics_cycle_analytics_value_streams_path(namespace_id: project.group.to_param, project_id: project.to_param)
puts "----"
puts Rails.application.routes.url_helpers.namespace_project_analytics_cycle_analytics_value_stream_path(id: value_stream.id, namespace_id: project.group.to_param, project_id: project.to_param)
  1. Visit the URLs and verify that it returns data

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 #382493 (closed)

Edited by Adam Hegyi

Merge request reports