Add line change metrics to contributor graphs

What does this MR do and why?

Add line change metrics to contributor graphs

Users need to inspect contributor activity by lines changed, not only commit totals. Keep commits as the default metric and allow switching charts between commits, additions, and deletions.

The default Commits view keeps the initial contributor analytics request lightweight. Line change stats are requested lazily only when a user selects Additions or Deletions. That follow-up request uses with_stats=true and still respects the existing 6,000 commit cap.

Changelog: changed

References

Resolves #14875

Performance

The initial JSON response does not include additions or deletions, so loading the default Commits view does not call commit.stats for each commit.

When a user selects Additions or Deletions, the frontend requests stats explicitly and merges them into the existing commit data by commit ID. This keeps the expensive stats lookup behind an explicit UI action while preserving the existing 6,000 commit cap.

Screenshots or screen recordings

The After screenshots show the Additions metric selected. The after-top-* screenshots include the branch selector, history button, and Contributions dropdown when they do not fit cleanly in the main viewport capture.

Viewport size Before After
xs (<576px) before-xs after-xs after-top-xs
sm (>=576px) before-sm after-sm after-top-sm
md (>=768px) before-md after-md after-top-md
lg (>=992px) before-lg after-lg after-top-lg
xl (>=1200px) before-xl after-xl after-top-xl

How to set up and validate locally

./node_modules/.bin/jest spec/frontend/contributors/store/actions_spec.js spec/frontend/contributors/store/mutations_spec.js spec/frontend/contributors/store/getters_spec.js spec/frontend/contributors/component/contributors_spec.js spec/frontend/contributors/component/individual_chart_spec.js spec/frontend/contributors/component/contributor_area_chart_spec.js --no-coverage

./node_modules/.bin/eslint app/assets/javascripts/contributors/components/contributor_area_chart.vue app/assets/javascripts/contributors/components/contributors.vue app/assets/javascripts/contributors/components/individual_chart.vue app/assets/javascripts/contributors/services/contributors_service.js app/assets/javascripts/contributors/stores/actions.js app/assets/javascripts/contributors/stores/getters.js app/assets/javascripts/contributors/stores/mutation_types.js app/assets/javascripts/contributors/stores/mutations.js app/assets/javascripts/contributors/stores/state.js spec/frontend/contributors/component/contributor_area_chart_spec.js spec/frontend/contributors/component/contributors_spec.js spec/frontend/contributors/component/individual_chart_spec.js spec/frontend/contributors/store/actions_spec.js spec/frontend/contributors/store/getters_spec.js spec/frontend/contributors/store/mutations_spec.js

./node_modules/.bin/prettier --check app/assets/javascripts/contributors/components/contributor_area_chart.vue app/assets/javascripts/contributors/components/contributors.vue app/assets/javascripts/contributors/components/individual_chart.vue app/assets/javascripts/contributors/services/contributors_service.js app/assets/javascripts/contributors/stores/actions.js app/assets/javascripts/contributors/stores/getters.js app/assets/javascripts/contributors/stores/mutation_types.js app/assets/javascripts/contributors/stores/mutations.js app/assets/javascripts/contributors/stores/state.js spec/frontend/contributors/component/contributor_area_chart_spec.js spec/frontend/contributors/component/contributors_spec.js spec/frontend/contributors/component/individual_chart_spec.js spec/frontend/contributors/store/actions_spec.js spec/frontend/contributors/store/getters_spec.js spec/frontend/contributors/store/mutations_spec.js

mise exec -- bundle exec rubocop app/controllers/projects/graphs_controller.rb spec/controllers/projects/graphs_controller_spec.rb

mise exec -- bundle exec rspec spec/controllers/projects/graphs_controller_spec.rb:47 spec/controllers/projects/graphs_controller_spec.rb:65

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.

Related to #14875

Edited by Aleksandr Kotlyar

Merge request reports

Loading