diff options
Diffstat (limited to 'app/experiments/new_project_readme_experiment.rb')
-rw-r--r-- | app/experiments/new_project_readme_experiment.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/app/experiments/new_project_readme_experiment.rb b/app/experiments/new_project_readme_experiment.rb index 8f88ad2adc1..c5c41330949 100644 --- a/app/experiments/new_project_readme_experiment.rb +++ b/app/experiments/new_project_readme_experiment.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class NewProjectReadmeExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass - include Gitlab::Git::WrapsGitalyErrors + include ProjectCommitCount INITIAL_WRITE_LIMIT = 3 EXPERIMENT_START_DATE = DateTime.parse('2021/1/20') @@ -21,25 +21,18 @@ class NewProjectReadmeExperiment < ApplicationExperiment # rubocop:disable Gitla def track_initial_writes(project) return unless should_track? # early return if we don't need to ask for commit counts return unless project.created_at > EXPERIMENT_START_DATE # early return for older projects - return unless (commit_count = commit_count_for(project)) < INITIAL_WRITE_LIMIT + return unless (count = commit_count(project)) < INITIAL_WRITE_LIMIT - track(:write, property: project.created_at.to_s, value: commit_count) + track(:write, property: project.created_at.to_s, value: count) end private - def commit_count_for(project) - raw_repo = project.repository&.raw_repository - return INITIAL_WRITE_LIMIT unless raw_repo&.root_ref - - begin - Gitlab::GitalyClient::CommitService.new(raw_repo).commit_count(raw_repo.root_ref, { - all: true, # include all branches - max_count: INITIAL_WRITE_LIMIT # limit as an optimization - }) - rescue StandardError => e - Gitlab::ErrorTracking.track_exception(e, experiment: name) - INITIAL_WRITE_LIMIT - end + def commit_count(project) + commit_count_for(project, + default_count: INITIAL_WRITE_LIMIT, + max_count: INITIAL_WRITE_LIMIT, + experiment: name + ) end end |