7e6f6e1603
Enables frozens string for the following: * lib/gitlab/conflict/**/*.rb * lib/gitlab/cross_project_access/**/*.rb * lib/gitlab/cycle_analytics/**/*.rb * lib/gitlab/data_builder/**/*.rb * lib/gitlab/database/**/*.rb * lib/gitlab/dependency_linker/**/*.rb * lib/gitlab/diff/**/*.rb * lib/gitlab/downtime_check/**/*.rb * lib/gitlab/email/**/*.rb * lib/gitlab/etag_caching/**/*.rb Partially addresses gitlab-org/gitlab-ce#47424.
37 lines
912 B
Ruby
37 lines
912 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module CycleAnalytics
|
|
module Summary
|
|
class Commit < Base
|
|
def title
|
|
n_('Commit', 'Commits', value)
|
|
end
|
|
|
|
def value
|
|
@value ||= count_commits
|
|
end
|
|
|
|
private
|
|
|
|
# Don't use the `Gitlab::Git::Repository#log` method, because it enforces
|
|
# a limit. Since we need a commit count, we _can't_ enforce a limit, so
|
|
# the easiest way forward is to replicate the relevant portions of the
|
|
# `log` function here.
|
|
def count_commits
|
|
return unless ref
|
|
|
|
gitaly_commit_client.commit_count(ref, after: @from)
|
|
end
|
|
|
|
def gitaly_commit_client
|
|
Gitlab::GitalyClient::CommitService.new(@project.repository.raw_repository)
|
|
end
|
|
|
|
def ref
|
|
@ref ||= @project.default_branch.presence
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|