Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions actions/marathonChallenges.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
*
* @version 1.4
* @version 1.5
* @author Sky_, TCSASSEMBLER, freegod, Ghost_141, hesibo
* changes in 1.1:
* - implement marathon API
Expand All @@ -12,6 +12,8 @@
* changes in 1.4:
* - Implement the get marathon match challenge register info API
* - refactor register marathon match challenge API
* Changes in 1.5:
* - Update search marathon match challenges. Add challengeName filter.
*/
"use strict";
var async = require('async');
Expand Down Expand Up @@ -62,6 +64,7 @@ var databaseDateFormat = "yyyy-MM-dd";
var FILTER_COLUMS = [
"roundId",
"fullName",
"challengeName",
"shortName",
"startDate.type",
"startDate.firstDate",
Expand Down Expand Up @@ -163,6 +166,7 @@ exports.searchMarathonChallenges = {
);
filter.roundId = params.roundId ? Number(params.roundId) : null;
filter.fullName = params.fullName;
filter.challengeName = params.challengeName;
filter.shortName = params.shortName;
filter.winnerHandle = params.winnerHandle;
filter.winnerScoreLowerBound = Number(params.winnerScoreLowerBound || 0);
Expand Down Expand Up @@ -207,7 +211,7 @@ exports.searchMarathonChallenges = {
sortColumn: helper.getSortColumnDBName(sortColumn),
sortOrder: sortOrder,
round_id: filter.roundId || 0,
full_name: filter.fullName || "",
full_name: filter.challengeName || filter.fullName || "",
short_name: filter.shortName || "",
winner_handle: filter.winnerHandle || "",
score_lower: filter.winnerScoreLowerBound,
Expand Down
11 changes: 8 additions & 3 deletions actions/srmChallenges.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2013-2014 TopCoder Inc., All Rights Reserved.
*
* @version 1.6
* @version 1.7
* @author Sky_, freegod, panoptimum, Ghost_141
* changes in 1.1:
* - implement srm API
Expand All @@ -22,6 +22,8 @@
* - added API for retrieving SRM schedule
* Changes in 1.6:
* - Update search srm challenges api to use informixoltp database.
* Changes in 1.7:
* - Update search srm challenges api. Add challengeName filter.
*/
/*jslint node: true, nomen: true */
"use strict";
Expand Down Expand Up @@ -179,7 +181,7 @@ exports.searchSRMChallenges = {
description: "searchSRMChallenges",
inputs: {
required: [],
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder", "listType"]
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder", "listType", "challengeName"]
},
blockedConnectionTypes: [],
outputExample: {},
Expand All @@ -189,7 +191,7 @@ exports.searchSRMChallenges = {
run: function (api, connection, next) {
api.log("Execute searchSRMChallenges#run", 'debug');
var helper = api.helper, params = connection.params, sqlParams, listType,
pageIndex, pageSize, sortColumn, sortOrder, error, result, status,
pageIndex, pageSize, sortColumn, sortOrder, error, result, status, challengeName,
dbConnectionMap = connection.dbConnectionMap;
if (!dbConnectionMap) {
helper.handleNoConnection(api, connection, next);
Expand All @@ -205,6 +207,7 @@ exports.searchSRMChallenges = {
pageIndex = Number(params.pageIndex || 1);
pageSize = Number(params.pageSize || DEFAULT_PAGE_SIZE);
listType = (params.listType || 'ACTIVE').toUpperCase();
challengeName = '%' + params.challengeName.toLowerCase() + '%' || '%';

if (!_.isDefined(params.sortOrder) && sortColumn === "roundid") {
sortOrder = "desc";
Expand All @@ -229,6 +232,7 @@ exports.searchSRMChallenges = {
helper.checkPositiveInteger(pageSize, "pageSize") ||
helper.checkContains(["asc", "desc"], sortOrder, "sortOrder") ||
helper.checkContains([helper.ListType.ACTIVE, helper.ListType.UPCOMING], listType, 'listType') ||
_.checkArgument(challengeName.length <= 32, 'The challengeName should less than 32 characters.') ||
helper.checkContains(allowedSort, sortColumn, "sortColumn");
if (error) {
cb(error);
Expand All @@ -244,6 +248,7 @@ exports.searchSRMChallenges = {
pageSize: pageSize,
sortColumn: helper.getSortColumnDBName(sortColumn),
sortOrder: sortOrder,
challengeName: challengeName,
status: status
};

Expand Down
2 changes: 1 addition & 1 deletion queries/get_srm_challenges
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ LEFT JOIN (
) rd2 ON rd2.round_id = r.round_id
WHERE r.status = '@status@'
AND r.round_type_id IN (1, 2, 10)

AND r.name LIKE ('@challengeName@')
ORDER BY @sortColumn@ @sortOrder@, round_id desc
1 change: 1 addition & 0 deletions queries/get_srm_challenges_count
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SELECT COUNT(*) AS total_count
FROM round r
WHERE r.status = '@status@'
AND r.round_type_id IN (1, 2, 10)
AND r.name LIKE ('@challengeName@')