Commit e32b6b6e authored by Bob Van Landuyt's avatar Bob Van Landuyt

Remove the commit count from the commits API

This removes the feature flag that was removing the commit count from
the API.

The commit count was adding an extra Gitaly call to populate the total
headers.
parent 021ec839
---
title: Remove the commit count from the commits API
merge_request: 44934
author:
type: performance
---
name: api_commits_without_count
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43159
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/254994
type: development
group: team::Scalability
default_enabled: false
......@@ -64,7 +64,6 @@ module API
serializer = with_stats ? Entities::CommitWithStats : Entities::Commit
if Feature.enabled?(:api_commits_without_count, user_project)
# This tells kaminari that there is 1 more commit after the one we've
# loaded, meaning there will be a next page, if the currently loaded set
# of commits is equal to the requested page size.
......@@ -72,19 +71,6 @@ module API
paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count)
present paginate(paginated_commits, exclude_total_headers: true), with: serializer
else
commit_count =
if all || path || before || after || first_parent
user_project.repository.count_commits(ref: ref, path: path, before: before, after: after, all: all, first_parent: first_parent)
else
# Cacheable commit count.
user_project.repository.commit_count_for_ref(ref)
end
paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count)
present paginate(paginated_commits), with: serializer
end
end
desc 'Commit multiple file changes as one commit' do
......
......@@ -40,17 +40,6 @@ RSpec.describe API::Commits do
expect(response).to include_limited_pagination_headers
end
it 'includes the total headers when the count is not disabled' do
stub_feature_flags(api_commits_without_count: false)
commit_count = project.repository.count_commits(ref: 'master').to_s
get api(route, current_user)
expect(response).to include_pagination_headers
expect(response.headers['X-Total']).to eq(commit_count)
expect(response.headers['X-Page']).to eql('1')
end
end
context 'when unauthenticated', 'and project is public' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment