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

Commit 971c681

Browse files
author
fireice.topcoder
committed
Merge branch 'dev' of github.com:cloudspokes/tc-api into dev
2 parents ed81d85 + 790a1d8 commit 971c681

19 files changed

+438
-68
lines changed

actions/rounds.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var TIME_FILTER_COLUMNS = [
6565

6666
// the sort columns
6767
var SORT_COLUMNS = {
68+
"name": "name",
6869
"registrationPhaseStartTime": "start_time_1",
6970
"registrationPhaseEndTime": "end_time_1",
7071
"codingPhaseStartTime": "start_time_2",
@@ -274,7 +275,7 @@ var getRounds = function (api, connection, dbConnectionMap, next) {
274275
filterCondition = ' r.round_id > 0 ';
275276
if (_.isDefined(params.name)) {
276277
// set name filter
277-
filterCondition = filterCondition + ' AND LOWER(name) LIKE LOWER("%' + decodeURIComponent(params.name) + '%")';
278+
filterCondition = filterCondition + ' AND LOWER(r.name) LIKE LOWER("%' + decodeURIComponent(params.name) + '%")';
278279
}
279280

280281
if (statusCondition !== '') {
@@ -344,7 +345,15 @@ var getRounds = function (api, connection, dbConnectionMap, next) {
344345
"registrationLimit": rounds[i].registration_limit,
345346
"invitationalType": rounds[i].invitational ? rounds[i].invitational.trim() : rounds[i].invitational,
346347
"region": rounds[i].region_name,
347-
"roundSchedule": []
348+
"contestId": rounds[i].contest_id,
349+
"contestName": rounds[i].contest_name,
350+
"contestStatus": rounds[i].contest_status,
351+
"hasProblems": rounds[i].has_problems.trim() === 'true',
352+
"hasTerms": rounds[i].has_terms.trim() === 'true',
353+
"hasSchedule": rounds[i].has_schedule.trim() === 'true',
354+
"hasQuestions": rounds[i].has_questions.trim() === 'true',
355+
"roundSchedule": [],
356+
"languages": []
348357
};
349358

350359
for (j = 1; j <= 7; j++) {
@@ -364,26 +373,43 @@ var getRounds = function (api, connection, dbConnectionMap, next) {
364373

365374
if (idStr !== '') {
366375
sqlParams.roundIdList = idStr;
367-
// get round terms
368-
api.dataAccess.executeQuery("get_round_terms_by_ids",
369-
sqlParams,
370-
dbConnectionMap,
371-
cb);
376+
async.parallel({
377+
languages: function (cbx) {
378+
api.dataAccess.executeQuery("get_round_language_by_ids",
379+
sqlParams,
380+
dbConnectionMap,
381+
cbx);
382+
},
383+
terms: function (cbx) {
384+
api.dataAccess.executeQuery("get_round_terms_by_ids",
385+
sqlParams,
386+
dbConnectionMap,
387+
cbx);
388+
}
389+
}, cb);
372390
} else {
373391
cb(null, null);
374392
}
375393
}, function (results, cb) {
376394
var j;
377395
if (results !== null) {
378-
for (i = 0; i < results.length; i++) {
396+
for (i = 0; i < results.terms.length; i++) {
379397
for (j = 0; j < data.length; j++) {
380398
// only return the first term
381-
if (results[i].round_id === data[j].id && !data[j]["roundTerms"]) {
382-
data[j]["roundTerms"] = results[i].terms_content;
399+
if (results.terms[i].round_id === data[j].id && !data[j]["roundTerms"]) {
400+
data[j]["roundTerms"] = results.terms[i].terms_content;
383401
break;
384402
}
385403
}
386404
}
405+
406+
for (i = 0; i < results.languages.length; i++) {
407+
for (j = 0; j < data.length; j++) {
408+
if (results.languages[i].round_id === data[j].id) {
409+
data[j]["languages"].push({"id": results.languages[i].language_id, "description": results.languages[i].language_name});
410+
}
411+
}
412+
}
387413
}
388414

389415
result.data = data;
@@ -408,7 +434,7 @@ exports.getRounds = {
408434
description: "Get Rounds",
409435
inputs: {
410436
required: [],
411-
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder"].concat(FILTER_COLUMNS).concat(TIME_FILTER_COLUMNS)
437+
optional: ["pageSize", "pageIndex", "sortColumn", "sortOrder", "name"].concat(FILTER_COLUMNS).concat(TIME_FILTER_COLUMNS)
412438
},
413439
blockedConnectionTypes: [],
414440
outputExample: {},

apiary.apib

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6943,31 +6943,35 @@ Request
69436943
"roundId": 6,
69446944
"roundName": "Past Srm Round",
69456945
"divisionDescription": "Unrated Division",
6946-
"levelDescription": "Level 2001"
6946+
"levelDescription": "Level 2001",
6947+
"editorialLink": "http://editlink6"
69476948
},
69486949
{
69496950
"contestId": 3006,
69506951
"contestName": "Contest 3006",
69516952
"roundId": 7,
69526953
"roundName": "Past Tournament Round",
69536954
"divisionDescription": "Division-I",
6954-
"levelDescription": "Level 2001"
6955+
"levelDescription": "Level 2001",
6956+
"editorialLink": "http://editlink7"
69556957
},
69566958
{
69576959
"contestId": 3007,
69586960
"contestName": "Contest 3007",
69596961
"roundId": 8,
69606962
"roundName": "Past Long Round",
69616963
"divisionDescription": "Division-II",
6962-
"levelDescription": "Level 2001"
6964+
"levelDescription": "Level 2001",
6965+
"editorialLink": "http://editlink8"
69636966
},
69646967
{
69656968
"contestId": 3008,
69666969
"contestName": "Contest 3008",
69676970
"roundId": 9,
69686971
"roundName": "Past Event Round",
69696972
"divisionDescription": "No Division Applicable",
6970-
"levelDescription": "Level 2001"
6973+
"levelDescription": "Level 2001",
6974+
"editorialLink": "http://editlink9"
69716975
}
69726976
]
69736977
}
@@ -8297,7 +8301,7 @@ Request
82978301
},
82988302
"languages": {
82998303
"roundId": 40006,
8300-
languages [
8304+
"languages": [
83018305
{
83028306
"id": 1,
83038307
"description": "Java"
@@ -15783,7 +15787,7 @@ Source Code Image Generation APIs
1578315787
+ Parameters
1578415788
+ pageIndex (optional, number, `1`) ... The paging number, 1-based, -1 if no paging. It can be null.
1578515789
+ pageSize (optional, number, `50`) ... The max number of the results, should be set if pageIndex is set.
15786-
+ sortColumn (optional, string, `registrationPhaseStartTime`) ... The column name to sort, can be null. It should be one of registrationPhaseStartTime, registrationPhaseEndTime, codingPhaseStartTime, codingPhaseEndTime, intermissionPhaseStartTime, intermissionPhaseEndTime, challengePhaseStartTime, challengePhaseEndTime, systemTestPhaseStartTime, systemTestPhaseEndTime, roomAssignmentPhaseStartTime, roomAssignmentPhaseEndTime, moderatedChatPhaseStartTime, moderatedChatPhaseEndTime.
15790+
+ sortColumn (optional, string, `registrationPhaseStartTime`) ... The column name to sort, can be null. It should be one of name,registrationPhaseStartTime, registrationPhaseEndTime, codingPhaseStartTime, codingPhaseEndTime, intermissionPhaseStartTime, intermissionPhaseEndTime, challengePhaseStartTime, challengePhaseEndTime, systemTestPhaseStartTime, systemTestPhaseEndTime, roomAssignmentPhaseStartTime, roomAssignmentPhaseEndTime, moderatedChatPhaseStartTime, moderatedChatPhaseEndTime.
1578715791
+ sortOrder (optional, string, `desc`) ... The sort order, can be null. It should be one of desc or asc.
1578815792
+ name (optional, string, `test`) ... The name filter, can be null. It should be encoded in uri format. It's case insensitive and it could be only part of name to filter.
1578915793
+ type (optional, string, `Single%20Round%20Match`) ... The type filter, can be null. It should be encoded in uri format. It's case insensitive. It should be values in round_type_lu table description field. It could use ',' char to connect more than 1 value.
@@ -15838,6 +15842,13 @@ Source Code Image Generation APIs
1583815842
"Registration Limit": 1000,
1583915843
"Invitational Type": "Not",
1584015844
"Region": "Alpha",
15845+
"contestId": 12917,
15846+
"contestName": "Test SRM",
15847+
"contestStatus": "A",
15848+
"hasProblems": true,
15849+
"hasTerms": true,
15850+
"hasSchedule": true,
15851+
"hasQuestions": false,
1584115852
"Round Schedule": [
1584215853
{
1584315854
"Phase Name": "Registration Phase",
@@ -15881,7 +15892,17 @@ Source Code Image Generation APIs
1588115892
"End Time": "2013-12-15T05:50:51.000+05:00",
1588215893
"Status": "Draft"
1588315894
}
15884-
]
15895+
],
15896+
"languages": [
15897+
{
15898+
"id": 1,
15899+
"description": "Java"
15900+
},
15901+
{
15902+
"id": 2,
15903+
"description": "XML"
15904+
}
15905+
]
1588515906
}
1588615907
]
1588715908
}

queries/get_round_language_by_ids

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select rl.round_id as round_id, l.language_id as language_id, l.language_name as language_name from round_language rl, language l where rl.language_id = l.language_id and rl.round_id in (@roundIdList@)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_round_language_by_ids",
3+
"db" : "informixoltp",
4+
"sqlfile" : "get_round_language_by_ids"
5+
}

queries/get_rounds

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ SELECT
55
r.name as name,
66
r.short_name as short_name,
77
rt.round_type_desc,
8+
c.contest_id as contest_id,
9+
c.name as contest_name,
10+
c.status as contest_status,
811
CASE WHEN (UPPER(r.status) = 'A') THEN
912
'Active'
1013
WHEN (UPPER(r.status) = 'P') THEN
@@ -99,12 +102,31 @@ SELECT
99102
'Draft'
100103
ELSE NULL
101104
END as status_7,
102-
(select segment_desc from segment where segment_id = 7) as name_7
105+
(select segment_desc from segment where segment_id = 7) as name_7,
106+
CASE WHEN ((select count(*) from round_component rc where rc.round_id = r.round_id) > 0) THEN
107+
'true'
108+
ELSE 'false'
109+
END AS has_problems,
110+
CASE WHEN ((select count(*) from round_terms rt where rt.round_id = r.round_id) > 0) THEN
111+
'true'
112+
ELSE 'false'
113+
END AS has_terms,
114+
CASE WHEN ((select count(*) from round_segment rs where rs.round_id = r.round_id) > 0) THEN
115+
'true'
116+
ELSE 'false'
117+
END AS has_schedule,
118+
CASE WHEN ((select count(*) from round_question rq where rq.round_id = r.round_id) > 0) THEN
119+
'true'
120+
ELSE 'false'
121+
END AS has_questions
122+
103123
FROM (round r
104124
LEFT OUTER JOIN round_type_lu rt
105125
ON r.round_type_id=rt.round_type_id
106126
LEFT OUTER JOIN region reg
107127
ON r.region_id=reg.region_id
128+
LEFT OUTER JOIN contest c
129+
ON r.contest_id=c.contest_id
108130
LEFT OUTER JOIN round_segment rs1
109131
ON r.round_id=rs1.round_id and rs1.segment_id = 1
110132
LEFT OUTER JOIN round_segment rs2

queries/get_rounds_for_problem

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ SELECT
44
r.contest_id,
55
(SELECT name FROM contest c WHERE c.contest_id = r.contest_id) AS contest_name,
66
(SELECT division_desc FROM division_lu d WHERE p.division_id = d.division_id) AS division_description,
7-
p.level_desc AS level_description
7+
p.level_desc AS level_description,
8+
r.editorial_link
89
FROM
910
problem p,
1011
round r
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
DELETE FROM round_terms WHERE round_id >= 12001 and round_id < 13000;
1+
DELETE FROM round_language WHERE round_id >= 12001 and round_id < 13000;
2+
DELETE FROM round_terms WHERE round_id >= 12001 and round_id < 13000;
23
DELETE FROM round_segment WHERE round_id >= 12001 and round_id < 13000;
34
DELETE FROM round WHERE round_id >= 12001 and round_id < 13000;
45
DELETE FROM contest WHERE contest_id = 12001;

test/sqls/rounds/informixoltp__insert_test_data

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VA
1010
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 6, '2013-12-12 01:50:51', '2013-12-13 01:50:51', 'F');
1111
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 7, '2013-12-14 01:50:51', '2013-12-15 01:50:51', 'F');
1212

13+
INSERT INTO round_language(round_id, language_id) VALUES(12001, 1);
14+
INSERT INTO round_language(round_id, language_id) VALUES(12001, 2);
15+
1316

1417
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12002, 12001, 'test round 12002', 'A', 1000, 0, 2, 'short name 12002', 1);
1518

test/sqls/srmRoundsForProblem/topcoder_dw__insert

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@ INSERT INTO round_type_lu (round_type_id, round_type_desc, algo_rating_type_id)
3434
INSERT INTO round_type_lu (round_type_id, round_type_desc, algo_rating_type_id) VALUES (27, 'Marathon Match QA', NULL);
3535

3636
INSERT INTO contest (contest_id, name) VALUES (3000, 'Contest 3000');
37-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (1, 3000, 1, 'Active Srm Round', 'A');
37+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (1, 3000, 1, 'Active Srm Round', 'A', 'http://editlink1');
3838
INSERT INTO contest (contest_id, name) VALUES (3001, 'Contest 3001');
39-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (2, 3001, 1, 'Active Srm Round 2', 'A');
39+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (2, 3001, 1, 'Active Srm Round 2', 'A', 'http://editlink2');
4040
INSERT INTO contest (contest_id, name) VALUES (3002, 'Contest 3002');
41-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (3, 3002, 2, 'Active Tournament Round', 'A');
41+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (3, 3002, 2, 'Active Tournament Round', 'A', 'http://editlink3');
4242
INSERT INTO contest (contest_id, name) VALUES (3003, 'Contest 3003');
43-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (4, 3003, 10, 'Active Long Round', 'A');
43+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (4, 3003, 10, 'Active Long Round', 'A', 'http://editlink4');
4444
INSERT INTO contest (contest_id, name) VALUES (3004, 'Contest 3004');
45-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (5, 3004, 20, 'Active Event Round', 'A');
45+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (5, 3004, 20, 'Active Event Round', 'A','http://editlink5');
4646
INSERT INTO contest (contest_id, name) VALUES (3005, 'Contest 3005');
47-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (6, 3005, 1, 'Past Srm Round', 'P');
47+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (6, 3005, 1, 'Past Srm Round', 'P','http://editlink6');
4848
INSERT INTO contest (contest_id, name) VALUES (3006, 'Contest 3006');
49-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (7, 3006, 2, 'Past Tournament Round', 'P');
49+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (7, 3006, 2, 'Past Tournament Round', 'P','http://editlink7');
5050
INSERT INTO contest (contest_id, name) VALUES (3007, 'Contest 3007');
51-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (8, 3007, 10, 'Past Long Round', 'P');
51+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (8, 3007, 10, 'Past Long Round', 'P', 'http://editlink8');
5252
INSERT INTO contest (contest_id, name) VALUES (3008, 'Contest 3008');
53-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (9, 3008, 20, 'Past Event Round', 'P');
53+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (9, 3008, 20, 'Past Event Round', 'P','http://editlink9');
5454
INSERT INTO contest (contest_id, name) VALUES (3009, 'Contest 3009');
55-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (10, 3009, 3, 'Past Practice Round', 'P');
55+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (10, 3009, 3, 'Past Practice Round', 'P','http://editlink10');
5656
INSERT INTO contest (contest_id, name) VALUES (3010, 'Contest 3010');
57-
INSERT INTO round (round_id, contest_id, round_type_id, name, status) VALUES (11, 3010, 9, 'Past Tournament Practice Round', 'P');
57+
INSERT INTO round (round_id, contest_id, round_type_id, name, status, editorial_link) VALUES (11, 3010, 9, 'Past Tournament Practice Round', 'P','http://editlink11');
5858

5959
INSERT INTO room (room_id, round_id, name, division_id, division_desc) VALUES (4001, 1, 'Room 4001', -1, 'No Division Applicable');
6060
INSERT INTO room (room_id, round_id, name, division_id, division_desc) VALUES (4002, 2, 'Room 4002', 0, 'Unrated Division');

test/test.rounds.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ describe('Get rounds api', function () {
201201
});
202202

203203
// sortColumn
204-
it("sortColumn should be an element of registrationphasestarttime,registrationphaseendtime," +
204+
it("sortColumn should be an element of name,registrationphasestarttime,registrationphaseendtime," +
205205
"codingphasestarttime,codingphaseendtime,intermissionphasestarttime,intermissionphaseendtime," +
206206
"challengephasestarttime,challengephaseendtime,systemtestphasestarttime,systemtestphaseendtime," +
207207
"roomassignmentphasestarttime,roomassignmentphaseendtime,moderatedchatphasestarttime,moderatedchatphaseendtime.", function (done) {
208208
assertError("/v2/data/rounds?sortColumn=dd", 'heffan', 400,
209-
"sortColumn should be an element of registrationphasestarttime,registrationphaseendtime," +
209+
"sortColumn should be an element of name,registrationphasestarttime,registrationphaseendtime," +
210210
"codingphasestarttime,codingphaseendtime,intermissionphasestarttime,intermissionphaseendtime," +
211211
"challengephasestarttime,challengephaseendtime,systemtestphasestarttime,systemtestphaseendtime," +
212212
"roomassignmentphasestarttime,roomassignmentphaseendtime,moderatedchatphasestarttime,moderatedchatphaseendtime.", done);

0 commit comments

Comments
 (0)