Skip to content
Snippets Groups Projects
Commit d7c5dbe2 authored by Adam Hegyi's avatar Adam Hegyi
Browse files

Merge branch '431546-use-500-batch-size-for-ca' into 'master'

Increase the page size for the contributions GraphQL query

See merge request gitlab-org/gitlab!136724



Merged-by: Adam Hegyi's avatarAdam Hegyi <ahegyi@gitlab.com>
parents 5c97b61a 80bf927a
No related branches found
No related tags found
No related merge requests found
---
name: use_500_page_size_for_contribution_analytics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136724
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/431595
milestone: '16.6'
type: development
group: group::optimize
default_enabled: false
...@@ -84,10 +84,12 @@ export default { ...@@ -84,10 +84,12 @@ export default {
try { try {
const { endDate, nextStartDate } = this.limitPostgresqlRequests(startDate, this.endDate); const { endDate, nextStartDate } = this.limitPostgresqlRequests(startDate, this.endDate);
const pageSize = gon.features?.use500PageSizeForContributionAnalytics ? 500 : null;
const { data } = await this.$apollo.query({ const { data } = await this.$apollo.query({
query: contributionsQuery, query: contributionsQuery,
variables: { variables: {
first: pageSize,
fullPath: this.fullPath, fullPath: this.fullPath,
startDate, startDate,
endDate, endDate,
......
...@@ -3,10 +3,11 @@ query getContributionsData( ...@@ -3,10 +3,11 @@ query getContributionsData(
$startDate: ISO8601Date! $startDate: ISO8601Date!
$endDate: ISO8601Date! $endDate: ISO8601Date!
$nextPageCursor: String = "" $nextPageCursor: String = ""
$first: Int
) { ) {
group(fullPath: $fullPath) { group(fullPath: $fullPath) {
id id
contributions(from: $startDate, to: $endDate, after: $nextPageCursor) { contributions(from: $startDate, to: $endDate, first: $first, after: $nextPageCursor) {
nodes { nodes {
repoPushed repoPushed
mergeRequestsCreated mergeRequestsCreated
......
...@@ -23,6 +23,8 @@ def show ...@@ -23,6 +23,8 @@ def show
# https://gitlab.com/gitlab-org/gitlab/-/issues/428585 # https://gitlab.com/gitlab-org/gitlab/-/issues/428585
@data_source_clickhouse = Feature.enabled?(:clickhouse_data_collection, group) @data_source_clickhouse = Feature.enabled?(:clickhouse_data_collection, group)
push_frontend_feature_flag(:use_500_page_size_for_contribution_analytics, group)
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
......
...@@ -17,6 +17,9 @@ class ContributionsResolver < BaseResolver ...@@ -17,6 +17,9 @@ class ContributionsResolver < BaseResolver
"The end date must be within #{NUMBER_OF_DAYS} days after the start date." "The end date must be within #{NUMBER_OF_DAYS} days after the start date."
# rubocop:enable Layout/LineLength # rubocop:enable Layout/LineLength
max_page_size 500
default_page_size GitlabSchema.default_max_page_size # ensure backwards compability
def resolve(from:, to:) def resolve(from:, to:)
validate_date_range!(from, to) validate_date_range!(from, to)
......
...@@ -39,6 +39,7 @@ describe('Contribution Analytics App', () => { ...@@ -39,6 +39,7 @@ describe('Contribution Analytics App', () => {
wrapper = shallowMount(App, { wrapper = shallowMount(App, {
apolloProvider, apolloProvider,
propsData: { propsData: {
first: null,
fullPath: 'test', fullPath: 'test',
startDate: '2000-12-10', startDate: '2000-12-10',
endDate: '2000-12-31', endDate: '2000-12-31',
...@@ -71,6 +72,7 @@ describe('Contribution Analytics App', () => { ...@@ -71,6 +72,7 @@ describe('Contribution Analytics App', () => {
results.forEach((result) => results.forEach((result) =>
expect(resolver).toHaveBeenCalledWith({ expect(resolver).toHaveBeenCalledWith({
fullPath: wrapper.props('fullPath'), fullPath: wrapper.props('fullPath'),
first: null,
...result, ...result,
}), }),
); );
...@@ -95,6 +97,35 @@ describe('Contribution Analytics App', () => { ...@@ -95,6 +97,35 @@ describe('Contribution Analytics App', () => {
expect(findErrorAlert().text()).toEqual(wrapper.vm.$options.i18n.error); expect(findErrorAlert().text()).toEqual(wrapper.vm.$options.i18n.error);
}); });
it('fetches a page size of 500 when use_500_page_size_for_contribution_analytics is enabled', async () => {
gon.features = { use500PageSizeForContributionAnalytics: true };
const contributionsQueryResolver = jest
.fn()
.mockResolvedValueOnce(mockApiResponse({ endCursor: nextPageCursor }))
.mockResolvedValueOnce(mockApiResponse());
createWrapper({ contributionsQueryResolver, props: { dataSourceClickhouse: true } });
await waitForPromises();
expectGroupMembersTableToHaveData();
expectContributionsQueryResolverCalls(contributionsQueryResolver, [
{
first: 500,
startDate: '2000-12-10',
endDate: '2000-12-31',
nextPageCursor: '',
},
{
first: 500,
startDate: '2000-12-10',
endDate: '2000-12-31',
nextPageCursor,
},
]);
});
it('fetches Clickhouse data, using paginated requests when necessary', async () => { it('fetches Clickhouse data, using paginated requests when necessary', async () => {
const contributionsQueryResolver = jest const contributionsQueryResolver = jest
.fn() .fn()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment