Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 38888fe

Browse files
committed
Update search srm challenges api and search marathon challenges api.
1. Add challengeName filter in these two api.
1 parent 5bac4e6 commit 38888fe

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

actions/marathonChallenges.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
33
*
4-
* @version 1.4
4+
* @version 1.5
55
* @author Sky_, TCSASSEMBLER, freegod, Ghost_141, hesibo
66
* changes in 1.1:
77
* - implement marathon API
@@ -12,6 +12,8 @@
1212
* changes in 1.4:
1313
* - Implement the get marathon match challenge register info API
1414
* - refactor register marathon match challenge API
15+
* Changes in 1.5:
16+
* - Update search marathon match challenges. Add challengeName filter.
1517
*/
1618
"use strict";
1719
var async = require('async');
@@ -62,6 +64,7 @@ var databaseDateFormat = "yyyy-MM-dd";
6264
var FILTER_COLUMS = [
6365
"roundId",
6466
"fullName",
67+
"challengeName",
6568
"shortName",
6669
"startDate.type",
6770
"startDate.firstDate",
@@ -163,6 +166,7 @@ exports.searchMarathonChallenges = {
163166
);
164167
filter.roundId = params.roundId ? Number(params.roundId) : null;
165168
filter.fullName = params.fullName;
169+
filter.challengeName = params.challengeName;
166170
filter.shortName = params.shortName;
167171
filter.winnerHandle = params.winnerHandle;
168172
filter.winnerScoreLowerBound = Number(params.winnerScoreLowerBound || 0);
@@ -207,7 +211,7 @@ exports.searchMarathonChallenges = {
207211
sortColumn: helper.getSortColumnDBName(sortColumn),
208212
sortOrder: sortOrder,
209213
round_id: filter.roundId || 0,
210-
full_name: filter.fullName || "",
214+
full_name: filter.challengeName || filter.fullName || "",
211215
short_name: filter.shortName || "",
212216
winner_handle: filter.winnerHandle || "",
213217
score_lower: filter.winnerScoreLowerBound,

actions/srmChallenges.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (C) 2013-2014 TopCoder Inc., All Rights Reserved.
33
*
4-
* @version 1.6
4+
* @version 1.7
55
* @author Sky_, freegod, panoptimum, Ghost_141
66
* changes in 1.1:
77
* - implement srm API
@@ -22,6 +22,8 @@
2222
* - added API for retrieving SRM schedule
2323
* Changes in 1.6:
2424
* - Update search srm challenges api to use informixoltp database.
25+
* Changes in 1.7:
26+
* - Update search srm challenges api. Add challengeName filter.
2527
*/
2628
/*jslint node: true, nomen: true */
2729
"use strict";
@@ -179,7 +181,7 @@ exports.searchSRMChallenges = {
179181
description: "searchSRMChallenges",
180182
inputs: {
181183
required: [],
182-
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder", "listType"]
184+
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder", "listType", "challengeName"]
183185
},
184186
blockedConnectionTypes: [],
185187
outputExample: {},
@@ -189,7 +191,7 @@ exports.searchSRMChallenges = {
189191
run: function (api, connection, next) {
190192
api.log("Execute searchSRMChallenges#run", 'debug');
191193
var helper = api.helper, params = connection.params, sqlParams, listType,
192-
pageIndex, pageSize, sortColumn, sortOrder, error, result, status,
194+
pageIndex, pageSize, sortColumn, sortOrder, error, result, status, challengeName,
193195
dbConnectionMap = connection.dbConnectionMap;
194196
if (!dbConnectionMap) {
195197
helper.handleNoConnection(api, connection, next);
@@ -205,6 +207,7 @@ exports.searchSRMChallenges = {
205207
pageIndex = Number(params.pageIndex || 1);
206208
pageSize = Number(params.pageSize || DEFAULT_PAGE_SIZE);
207209
listType = (params.listType || 'ACTIVE').toUpperCase();
210+
challengeName = '%' + params.challengeName.toLowerCase() + '%' || '%';
208211

209212
if (!_.isDefined(params.sortOrder) && sortColumn === "roundid") {
210213
sortOrder = "desc";
@@ -229,6 +232,7 @@ exports.searchSRMChallenges = {
229232
helper.checkPositiveInteger(pageSize, "pageSize") ||
230233
helper.checkContains(["asc", "desc"], sortOrder, "sortOrder") ||
231234
helper.checkContains([helper.ListType.ACTIVE, helper.ListType.UPCOMING], listType, 'listType') ||
235+
_.checkArgument(challengeName.length <= 32, 'The challengeName should less than 32 characters.') ||
232236
helper.checkContains(allowedSort, sortColumn, "sortColumn");
233237
if (error) {
234238
cb(error);
@@ -244,6 +248,7 @@ exports.searchSRMChallenges = {
244248
pageSize: pageSize,
245249
sortColumn: helper.getSortColumnDBName(sortColumn),
246250
sortOrder: sortOrder,
251+
challengeName: challengeName,
247252
status: status
248253
};
249254

queries/get_srm_challenges

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ LEFT JOIN (
3737
) rd2 ON rd2.round_id = r.round_id
3838
WHERE r.status = '@status@'
3939
AND r.round_type_id IN (1, 2, 10)
40-
40+
AND r.name LIKE ('@challengeName@')
4141
ORDER BY @sortColumn@ @sortOrder@, round_id desc

queries/get_srm_challenges_count

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ SELECT COUNT(*) AS total_count
22
FROM round r
33
WHERE r.status = '@status@'
44
AND r.round_type_id IN (1, 2, 10)
5+
AND r.name LIKE ('@challengeName@')

0 commit comments

Comments
 (0)