Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

#5312 Fix limit submissions#309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
fikzzzy wants to merge2 commits intotopcoder-platform:bug-bash
base:bug-bash
Choose a base branch
Loading
fromfikzzzy:fix-limit-submissions
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletionssrc/actions/challenge.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,39 +12,7 @@ import { getService as getChallengesService } from '../services/challenges';
import { getService as getSubmissionService } from '../services/submissions';
import { getApi } from '../services/api';
import * as submissionUtil from '../utils/submission';

const { PAGE_SIZE } = CONFIG;

/**
* Private. Loads from the backend all data matching some conditions.
* @param {Function} getter Given params object of shape { limit, offset }
* loads from the backend at most "limit" data, skipping the first
* "offset" ones. Returns loaded data as an array.
* @param {Number} page Optional. Next page of data to load.
* @param {Number} perPage Optional. The size of the page content to load.
* @param {Array} prev Optional. data loaded so far.
*/
function getAll(getter, page = 1, perPage = PAGE_SIZE, prev) {
/* Amount of submissions to fetch in one API call. 50 is the current maximum
* amount of submissions the backend returns, event when the larger limit is
* explicitely required. */
return getter({
page,
perPage,
}).then((res) => {
if (res.length === 0) {
return prev || res;
}
// parse submissions
let current = [];
if (prev) {
current = prev.concat(res);
} else {
current = res;
}
return getAll(getter, 1 + page, perPage, current);
});
}
import { getAll } from '../utils/tc';

/**
* @static
Expand Down
10 changes: 6 additions & 4 deletionssrc/services/challenges.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import qs from 'qs';
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
import logger from '../utils/logger';
import { setErrorIcon, ERROR_ICON_TYPES } from '../utils/errors';
import { COMPETITION_TRACKS, getApiResponsePayload } from '../utils/tc';
import { COMPETITION_TRACKS,getAll,getApiResponsePayload } from '../utils/tc';
import { getApi } from './api';
import { getService as getMembersService } from './members';
import { getService as getSubmissionsService } from './submissions';
Expand DownExpand Up@@ -402,12 +402,14 @@ class ChallengesService {
if (memberId) {
isRegistered = _.some(registrants, r => `${r.memberId}` === `${memberId}`);

constsubParams = {
constfilter = {
challengeId,
perPage: challenge.numOfSubmissions ? challenge.numOfSubmissions : 100,
};

submissions = await this.private.submissionsService.getSubmissions(subParams);
submissions = await getAll(
params => this.private.submissionsService.getSubmissions(filter, params),
1,
);

if (submissions) {
// Remove AV Scan, SonarQube Review and Virus Scan review types
Expand Down
2 changes: 1 addition & 1 deletionsrc/services/submissions.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ class SubmissionsService {
* @param {Object} params
* @return {Promise} Resolves to the api response.
*/
async getSubmissions(filters, params) {
async getSubmissions(filters, params = {}) {
const query = {
...filters,
...params,
Expand Down
31 changes: 31 additions & 0 deletionssrc/utils/tc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,3 +101,34 @@ export async function getLookerApiResponsePayload(res) {
status: x.status,
};
}

/**
* Private. Loads from the backend all data matching some conditions.
* @param {Function} getter Given params object of shape { limit, offset }
* loads from the backend at most "limit" data, skipping the first
* "offset" ones. Returns loaded data as an array.
* @param {Number} page Optional. Next page of data to load.
* @param {Number} perPage Optional. The size of the page content to load.
* @param {Array} prev Optional. data loaded so far.
*/
export function getAll(getter, page = 1, perPage = 500, prev) {
/* Amount of items to fetch in one API call. 50 is the current maximum
* amount of items the backend returns, event when the larger limit is
* explicitely required. */
return getter({
page,
perPage,
}).then((res) => {
if (res.length === 0) {
return prev || res;
}
// parse items
let current = [];
if (prev) {
current = prev.concat(res);
} else {
current = res;
}
return getAll(getter, 1 + page, perPage, current);
});
}

[8]ページ先頭

©2009-2025 Movatter.jp