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

Commit e629991

Browse files
committed
Merge pull request #398 from flytoj2ee/dev
TC API - Get Rounds API
2 parents 808ed5e + 873c362 commit e629991

22 files changed

+2882
-3
lines changed

actions/rounds.js

Lines changed: 426 additions & 0 deletions
Large diffs are not rendered by default.

apiary.apib

Lines changed: 357 additions & 0 deletions
Large diffs are not rendered by default.

queries/get_data_round_type_lu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT DISTINCT round_type_desc AS name
2+
, round_type_id AS id
3+
FROM round_type_lu
4+
ORDER BY name ASC;

queries/get_data_round_type_lu.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_data_round_type_lu",
3+
"db" : "informixoltp",
4+
"sqlfile" : "get_data_round_type_lu"
5+
}

queries/get_round_terms_by_ids

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select round_id, terms_content from round_terms where round_id in (@roundIdList@)

queries/get_round_terms_by_ids.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_round_terms_by_ids",
3+
"db" : "informixoltp",
4+
"sqlfile" : "get_round_terms_by_ids"
5+
}

queries/get_rounds

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
SELECT
2+
SKIP @firstRowIndex@
3+
FIRST @pageSize@
4+
r.round_id as id,
5+
r.name as name,
6+
r.short_name as short_name,
7+
rt.round_type_desc,
8+
CASE WHEN (UPPER(r.status) = 'A') THEN
9+
'Active'
10+
WHEN (UPPER(r.status) = 'P') THEN
11+
'Past'
12+
WHEN (UPPER(r.status) = 'F') THEN
13+
'Draft'
14+
ELSE NULL
15+
END AS round_status,
16+
r.registration_limit,
17+
CASE WHEN (r.invitational = 0) THEN
18+
'Not'
19+
WHEN (r.invitational = 1) THEN
20+
'Normal'
21+
WHEN (r.invitational = 2) THEN
22+
'Negate'
23+
ELSE NULL
24+
END AS invitational,
25+
reg.region_name,
26+
rs1.start_time as start_time_1,
27+
rs1.end_time as end_time_1,
28+
CASE WHEN (UPPER(rs1.status) = 'A') THEN
29+
'Active'
30+
WHEN (UPPER(rs1.status) = 'P') THEN
31+
'Past'
32+
WHEN (UPPER(rs1.status) = 'F') THEN
33+
'Draft'
34+
ELSE NULL
35+
END as status_1,
36+
((select segment_desc from segment where segment_id = 1) || ' Phase') as name_1,
37+
rs2.start_time as start_time_2,
38+
rs2.end_time as end_time_2,
39+
CASE WHEN (UPPER(rs2.status) = 'A') THEN
40+
'Active'
41+
WHEN (UPPER(rs2.status) = 'P') THEN
42+
'Past'
43+
WHEN (UPPER(rs2.status) = 'F') THEN
44+
'Draft'
45+
ELSE NULL
46+
END as status_2,
47+
(select segment_desc from segment where segment_id = 2) as name_2,
48+
rs3.start_time as start_time_3,
49+
rs3.end_time as end_time_3,
50+
CASE WHEN (UPPER(rs3.status) = 'A') THEN
51+
'Active'
52+
WHEN (UPPER(rs3.status) = 'P') THEN
53+
'Past'
54+
WHEN (UPPER(rs3.status) = 'F') THEN
55+
'Draft'
56+
ELSE NULL
57+
END as status_3,
58+
(select segment_desc from segment where segment_id = 3) as name_3,
59+
rs4.start_time as start_time_4,
60+
rs4.end_time as end_time_4,
61+
CASE WHEN (UPPER(rs4.status) = 'A') THEN
62+
'Active'
63+
WHEN (UPPER(rs4.status) = 'P') THEN
64+
'Past'
65+
WHEN (UPPER(rs4.status) = 'F') THEN
66+
'Draft'
67+
ELSE NULL
68+
END as status_4,
69+
(select segment_desc from segment where segment_id = 4) as name_4,
70+
rs5.start_time as start_time_5,
71+
rs5.end_time as end_time_5,
72+
CASE WHEN (UPPER(rs5.status) = 'A') THEN
73+
'Active'
74+
WHEN (UPPER(rs5.status) = 'P') THEN
75+
'Past'
76+
WHEN (UPPER(rs5.status) = 'F') THEN
77+
'Draft'
78+
ELSE NULL
79+
END as status_5,
80+
(select segment_desc from segment where segment_id = 5) as name_5,
81+
rs6.start_time as start_time_6,
82+
rs6.end_time as end_time_6,
83+
CASE WHEN (UPPER(rs6.status) = 'A') THEN
84+
'Active'
85+
WHEN (UPPER(rs6.status) = 'P') THEN
86+
'Past'
87+
WHEN (UPPER(rs6.status) = 'F') THEN
88+
'Draft'
89+
ELSE NULL
90+
END as status_6,
91+
(select segment_desc from segment where segment_id = 6) as name_6,
92+
rs7.start_time as start_time_7,
93+
rs7.end_time as end_time_7,
94+
CASE WHEN (UPPER(rs7.status) = 'A') THEN
95+
'Active'
96+
WHEN (UPPER(rs7.status) = 'P') THEN
97+
'Past'
98+
WHEN (UPPER(rs7.status) = 'F') THEN
99+
'Draft'
100+
ELSE NULL
101+
END as status_7,
102+
(select segment_desc from segment where segment_id = 7) as name_7
103+
FROM (round r
104+
LEFT OUTER JOIN round_type_lu rt
105+
ON r.round_type_id=rt.round_type_id
106+
LEFT OUTER JOIN region reg
107+
ON r.region_id=reg.region_id
108+
LEFT OUTER JOIN round_segment rs1
109+
ON r.round_id=rs1.round_id and rs1.segment_id = 1
110+
LEFT OUTER JOIN round_segment rs2
111+
ON r.round_id=rs2.round_id and rs2.segment_id = 2
112+
LEFT OUTER JOIN round_segment rs3
113+
ON r.round_id=rs3.round_id and rs3.segment_id = 3
114+
LEFT OUTER JOIN round_segment rs4
115+
ON r.round_id=rs4.round_id and rs4.segment_id = 4
116+
LEFT OUTER JOIN round_segment rs5
117+
ON r.round_id=rs5.round_id and rs5.segment_id = 5
118+
LEFT OUTER JOIN round_segment rs6
119+
ON r.round_id=rs6.round_id and rs6.segment_id = 6
120+
LEFT OUTER JOIN round_segment rs7
121+
ON r.round_id=rs7.round_id and rs7.segment_id = 7
122+
)
123+
WHERE @filterCondition@
124+
ORDER BY @sortColumn@ @sortOrder@

queries/get_rounds.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_rounds",
3+
"db" : "informixoltp",
4+
"sqlfile" : "get_rounds"
5+
}

queries/get_rounds_count

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SELECT
2+
count(*) as total_count
3+
FROM (round r
4+
LEFT OUTER JOIN round_type_lu rt
5+
ON r.round_type_id=rt.round_type_id
6+
LEFT OUTER JOIN region reg
7+
ON r.region_id=reg.region_id
8+
LEFT OUTER JOIN round_segment rs1
9+
ON r.round_id=rs1.round_id and rs1.segment_id = 1
10+
LEFT OUTER JOIN round_segment rs2
11+
ON r.round_id=rs2.round_id and rs2.segment_id = 2
12+
LEFT OUTER JOIN round_segment rs3
13+
ON r.round_id=rs3.round_id and rs3.segment_id = 3
14+
LEFT OUTER JOIN round_segment rs4
15+
ON r.round_id=rs4.round_id and rs4.segment_id = 4
16+
LEFT OUTER JOIN round_segment rs5
17+
ON r.round_id=rs5.round_id and rs5.segment_id = 5
18+
LEFT OUTER JOIN round_segment rs6
19+
ON r.round_id=rs6.round_id and rs6.segment_id = 6
20+
LEFT OUTER JOIN round_segment rs7
21+
ON r.round_id=rs7.round_id and rs7.segment_id = 7
22+
)
23+
WHERE @filterCondition@

queries/get_rounds_count.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_rounds_count",
3+
"db" : "informixoltp",
4+
"sqlfile" : "get_rounds_count"
5+
}

routes.js

Lines changed: 6 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.67
4+
* @version 1.68
55
* @author vangavroche, Sky_, muzehyun, kurtrips, Ghost_141, ecnu_haozi, hesibo, LazyChild, isv, flytoj2ee,
66
* @author panoptimum, bugbuka, Easyhard, TCASSEMBLER
77
*
@@ -154,6 +154,8 @@
154154
* - Added get user design challenges api.
155155
* Changed in 1.67:
156156
* - Added get user develop challenges api.
157+
* Changed in 1.68:
158+
* - Added get rounds api.
157159
*/
158160
/*jslint node:true, nomen: true */
159161
"use strict";
@@ -259,7 +261,7 @@ exports.routes = {
259261
{ path: "/:apiVersion/develop/reviewOpportunities/:challengeId", action: "getSoftwareReviewOpportunity" },
260262
{ path: "/:apiVersion/develop/reviewOpportunities", action: "searchReviewOpportunities" },
261263
{ path: "/:apiVersion/develop/download/:submissionId", action: "downloadDevSubmission" },
262-
264+
263265
{ path: "/:apiVersion/design/challengetypes", action: "studioTypes" },
264266
{ path: "/:apiVersion/design/challenges/result/:challengeId", action: "getStudioChallengeResults" },
265267
{ path: "/:apiVersion/design/reviewOpportunities/:id", action: "getStudioReviewOpportunity" },
@@ -270,7 +272,7 @@ exports.routes = {
270272

271273
{ path: "/:apiVersion/user/:handle/challenges/design", action: "getUserDesignChallenges" },
272274
{ path: "/:apiVersion/user/:handle/challenges/develop", action: "getUserDevelopChallenges" },
273-
275+
274276

275277
{ path: "/:apiVersion/user/challenges", action: "getMyChallenges" },
276278
{ path: "/:apiVersion/user/activation-email", action: "userActivationEmail" },
@@ -356,6 +358,7 @@ exports.routes = {
356358
{ path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "getRoundTerms" },
357359
{ path: "/:apiVersion/data/srm/rounds/:contestId", action: "listSRMContestRounds" },
358360
{ path: "/:apiVersion/auth0/callback", action: "auth0Callback" },
361+
{ path: "/:apiVersion/data/rounds", action: "getRounds" },
359362

360363
//Stubs APIs
361364
{ path: "/:apiVersion/data/reviewOpportunities/:id", action: "getAlgorithmsReviewOpportunity" },

test/sqls/rounds/informixoltp__clean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DELETE FROM round_terms WHERE round_id >= 12001 and round_id < 13000;
2+
DELETE FROM round_segment WHERE round_id >= 12001 and round_id < 13000;
3+
DELETE FROM round WHERE round_id >= 12001 and round_id < 13000;
4+
DELETE FROM contest WHERE contest_id = 12001;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
INSERT INTO contest(contest_id, name) VALUES(12001, 'test contest 12001');
2+
3+
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12001, 12001, 'test round 12001', 'A', 1000, 0, 1, 'short name 12001', 1);
4+
5+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 1, '2013-11-02 01:50:51', '2013-12-02 01:50:51', 'P');
6+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 2, '2013-12-02 01:50:52', '2013-12-05 01:50:51', 'P');
7+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 3, '2013-12-06 01:50:51', '2013-12-07 01:50:51', 'P');
8+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 4, '2013-12-08 01:50:51', '2013-12-09 01:50:51', 'P');
9+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12001, 5, '2013-12-10 01:50:51', '2013-12-11 01:50:51', 'A');
10+
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');
11+
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');
12+
13+
14+
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);
15+
16+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 1, '2014-11-02 01:50:51', '2014-12-02 01:50:51', 'P');
17+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 2, '2014-12-02 01:50:52', '2014-12-05 01:50:51', 'P');
18+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 3, '2014-12-06 01:50:51', '2014-12-07 01:50:51', 'P');
19+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 4, '2014-12-08 01:50:51', '2014-12-09 01:50:51', 'P');
20+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 5, '2014-12-10 01:50:51', '2014-12-11 01:50:51', 'A');
21+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 6, '2014-12-12 01:50:51', '2014-12-13 01:50:51', 'F');
22+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12002, 7, '2014-12-14 01:50:51', '2014-12-15 01:50:51', 'F');
23+
24+
25+
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12003, 12001, 'test round 12003', 'A', 1000, 0, 3, 'short name 12003', 1);
26+
27+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 1, '2013-08-02 01:50:51', '2013-09-02 01:50:51', 'P');
28+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 2, '2013-09-02 01:50:52', '2013-09-05 01:50:51', 'P');
29+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 3, '2013-09-06 01:50:51', '2013-09-07 01:50:51', 'P');
30+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 4, '2013-09-08 01:50:51', '2013-09-09 01:50:51', 'P');
31+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 5, '2013-09-10 01:50:51', '2013-09-11 01:50:51', 'A');
32+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 6, '2013-09-12 01:50:51', '2013-09-13 01:50:51', 'F');
33+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12003, 7, '2013-09-14 01:50:51', '2013-09-15 01:50:51', 'F');
34+
35+
36+
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12004, 12001, 'test round 12004', 'A', 1000, 0, 6, 'short name 12004', 1);
37+
38+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 1, '2013-01-02 01:50:51', '2013-02-02 01:50:51', 'P');
39+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 2, '2013-02-02 01:50:52', '2013-02-05 01:50:51', 'P');
40+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 3, '2013-02-06 01:50:51', '2013-02-07 01:50:51', 'P');
41+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 4, '2013-02-08 01:50:51', '2013-02-09 01:50:51', 'P');
42+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 5, '2013-02-10 01:50:51', '2013-02-11 01:50:51', 'A');
43+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 6, '2013-02-12 01:50:51', '2013-02-13 01:50:51', 'F');
44+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12004, 7, '2013-02-14 01:50:51', '2013-02-15 01:50:51', 'F');
45+
46+
47+
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12005, 12001, 'test round 12005', 'A', 1000, 0, 13, 'short name 12005', 1);
48+
49+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12005, 1, '2011-11-02 01:50:51', '2011-12-02 01:50:51', 'P');
50+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12005, 2, '2011-12-02 01:50:52', '2011-12-05 01:50:51', 'P');
51+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12005, 5, '2011-12-10 01:50:51', '2011-12-11 01:50:51', 'A');
52+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12005, 7, '2011-12-14 01:50:51', '2011-12-15 01:50:51', 'F');
53+
54+
55+
INSERT INTO round(round_id, contest_id, name, status, registration_limit, invitational, round_type_id, short_name, region_id) VALUES(12006, 12001, 'test round 12006', 'A', 1000, 0, 19, 'short name 12006', 1);
56+
57+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 1, '2015-11-02 01:50:51', '2015-12-02 01:50:51', 'P');
58+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 2, '2015-12-02 01:50:52', '2015-12-05 01:50:51', 'P');
59+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 3, '2015-12-06 01:50:51', '2015-12-07 01:50:51', 'P');
60+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 4, '2015-12-08 01:50:51', '2015-12-09 01:50:51', 'P');
61+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 5, '2015-12-10 01:50:51', '2015-12-11 01:50:51', 'A');
62+
INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(12006, 7, '2015-12-14 01:50:51', '2015-12-15 01:50:51', 'F');

0 commit comments

Comments
 (0)