Add controller and feature flag for code analytics
What does this MR do?
This MR adds a controller, feature flag for code analytics data. I also experiment with input parameter validation using ActiveModel.
Discovery Issue: #12683 (closed)
Implementation issue: #14672 (closed)
How to try it:
- Enable the feature:
Feature.enable(:code_analytics)
- Visit:
/-/analytics/code_analytics
- You should see an empty page (FE will be implemented here)
Getting Data from the API:
Execute in console:
project = Project.find_by_name!("Gitlab Test")
gemfile = Analytics::CodeAnalytics::RepositoryFile.create!(file_path: 'Gemfile', project: project)
user_model = Analytics::CodeAnalytics::RepositoryFile.create!(file_path: 'app/models/user.rb', project: project)
Analytics::CodeAnalytics::RepositoryFileCommit.create(project: project, commit_count: 2, committed_date: Date.today, analytics_repository_file: gemfile)
Analytics::CodeAnalytics::RepositoryFileCommit.create(project: project, commit_count: 5, committed_date: Date.yesterday, analytics_repository_file: gemfile)
Analytics::CodeAnalytics::RepositoryFileCommit.create(project: project, commit_count: 10, committed_date: Date.yesterday, analytics_repository_file: user_model)
Then visit:
/-/analytics/code_analytics.json?project_id=gitlab-org/gitlab-test&group_id=gitlab-org&file_count=4
Validation error:
/-/analytics/code_analytics.json?project_id=gitlab-org/gitlab-test&group_id=gitlab-org&file_count=1000
Screenshots
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation created/updated or follow-up review issue created
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Performance and Testing
Edited by Adam Hegyi