2021-02-05 19:09:54 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class NewProjectReadmeExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
|
2021-04-22 08:09:49 -04:00
|
|
|
include ProjectCommitCount
|
2021-02-05 19:09:54 -05:00
|
|
|
|
|
|
|
INITIAL_WRITE_LIMIT = 3
|
|
|
|
EXPERIMENT_START_DATE = DateTime.parse('2021/1/20')
|
|
|
|
MAX_ACCOUNT_AGE = 7.days
|
|
|
|
|
|
|
|
exclude { context.value[:actor].nil? }
|
|
|
|
exclude { context.actor.created_at < MAX_ACCOUNT_AGE.ago }
|
|
|
|
|
|
|
|
def control_behavior
|
|
|
|
false # we don't want the checkbox to be checked
|
|
|
|
end
|
|
|
|
|
|
|
|
def candidate_behavior
|
|
|
|
true # check the checkbox by default
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2021-04-22 08:09:49 -04:00
|
|
|
return unless (count = commit_count(project)) < INITIAL_WRITE_LIMIT
|
2021-02-05 19:09:54 -05:00
|
|
|
|
2021-04-22 08:09:49 -04:00
|
|
|
track(:write, property: project.created_at.to_s, value: count)
|
2021-02-05 19:09:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-04-22 08:09:49 -04:00
|
|
|
def commit_count(project)
|
|
|
|
commit_count_for(project,
|
|
|
|
default_count: INITIAL_WRITE_LIMIT,
|
|
|
|
max_count: INITIAL_WRITE_LIMIT,
|
|
|
|
experiment: name
|
|
|
|
)
|
2021-02-05 19:09:54 -05:00
|
|
|
end
|
|
|
|
end
|