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

TC API - Get Rounds API #398

Merged
merged 1 commit into from
Dec 31, 2014
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
426 changes: 426 additions & 0 deletions actions/rounds.js

Large diffs are not rendered by default.

357 changes: 357 additions & 0 deletions apiary.apib

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions queries/get_data_round_type_lu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT DISTINCT round_type_desc AS name
, round_type_id AS id
FROM round_type_lu
ORDER BY name ASC;
5 changes: 5 additions & 0 deletions queries/get_data_round_type_lu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_data_round_type_lu",
"db" : "informixoltp",
"sqlfile" : "get_data_round_type_lu"
}
1 change: 1 addition & 0 deletions queries/get_round_terms_by_ids
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select round_id, terms_content from round_terms where round_id in (@roundIdList@)
5 changes: 5 additions & 0 deletions queries/get_round_terms_by_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_round_terms_by_ids",
"db" : "informixoltp",
"sqlfile" : "get_round_terms_by_ids"
}
124 changes: 124 additions & 0 deletions queries/get_rounds
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
SELECT
SKIP @firstRowIndex@
FIRST @pageSize@
r.round_id as id,
r.name as name,
r.short_name as short_name,
rt.round_type_desc,
CASE WHEN (UPPER(r.status) = 'A') THEN
'Active'
WHEN (UPPER(r.status) = 'P') THEN
'Past'
WHEN (UPPER(r.status) = 'F') THEN
'Draft'
ELSE NULL
END AS round_status,
r.registration_limit,
CASE WHEN (r.invitational = 0) THEN
'Not'
WHEN (r.invitational = 1) THEN
'Normal'
WHEN (r.invitational = 2) THEN
'Negate'
ELSE NULL
END AS invitational,
reg.region_name,
rs1.start_time as start_time_1,
rs1.end_time as end_time_1,
CASE WHEN (UPPER(rs1.status) = 'A') THEN
'Active'
WHEN (UPPER(rs1.status) = 'P') THEN
'Past'
WHEN (UPPER(rs1.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_1,
((select segment_desc from segment where segment_id = 1) || ' Phase') as name_1,
rs2.start_time as start_time_2,
rs2.end_time as end_time_2,
CASE WHEN (UPPER(rs2.status) = 'A') THEN
'Active'
WHEN (UPPER(rs2.status) = 'P') THEN
'Past'
WHEN (UPPER(rs2.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_2,
(select segment_desc from segment where segment_id = 2) as name_2,
rs3.start_time as start_time_3,
rs3.end_time as end_time_3,
CASE WHEN (UPPER(rs3.status) = 'A') THEN
'Active'
WHEN (UPPER(rs3.status) = 'P') THEN
'Past'
WHEN (UPPER(rs3.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_3,
(select segment_desc from segment where segment_id = 3) as name_3,
rs4.start_time as start_time_4,
rs4.end_time as end_time_4,
CASE WHEN (UPPER(rs4.status) = 'A') THEN
'Active'
WHEN (UPPER(rs4.status) = 'P') THEN
'Past'
WHEN (UPPER(rs4.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_4,
(select segment_desc from segment where segment_id = 4) as name_4,
rs5.start_time as start_time_5,
rs5.end_time as end_time_5,
CASE WHEN (UPPER(rs5.status) = 'A') THEN
'Active'
WHEN (UPPER(rs5.status) = 'P') THEN
'Past'
WHEN (UPPER(rs5.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_5,
(select segment_desc from segment where segment_id = 5) as name_5,
rs6.start_time as start_time_6,
rs6.end_time as end_time_6,
CASE WHEN (UPPER(rs6.status) = 'A') THEN
'Active'
WHEN (UPPER(rs6.status) = 'P') THEN
'Past'
WHEN (UPPER(rs6.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_6,
(select segment_desc from segment where segment_id = 6) as name_6,
rs7.start_time as start_time_7,
rs7.end_time as end_time_7,
CASE WHEN (UPPER(rs7.status) = 'A') THEN
'Active'
WHEN (UPPER(rs7.status) = 'P') THEN
'Past'
WHEN (UPPER(rs7.status) = 'F') THEN
'Draft'
ELSE NULL
END as status_7,
(select segment_desc from segment where segment_id = 7) as name_7
FROM (round r
LEFT OUTER JOIN round_type_lu rt
ON r.round_type_id=rt.round_type_id
LEFT OUTER JOIN region reg
ON r.region_id=reg.region_id
LEFT OUTER JOIN round_segment rs1
ON r.round_id=rs1.round_id and rs1.segment_id = 1
LEFT OUTER JOIN round_segment rs2
ON r.round_id=rs2.round_id and rs2.segment_id = 2
LEFT OUTER JOIN round_segment rs3
ON r.round_id=rs3.round_id and rs3.segment_id = 3
LEFT OUTER JOIN round_segment rs4
ON r.round_id=rs4.round_id and rs4.segment_id = 4
LEFT OUTER JOIN round_segment rs5
ON r.round_id=rs5.round_id and rs5.segment_id = 5
LEFT OUTER JOIN round_segment rs6
ON r.round_id=rs6.round_id and rs6.segment_id = 6
LEFT OUTER JOIN round_segment rs7
ON r.round_id=rs7.round_id and rs7.segment_id = 7
)
WHERE @filterCondition@
ORDER BY @sortColumn@ @sortOrder@
5 changes: 5 additions & 0 deletions queries/get_rounds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_rounds",
"db" : "informixoltp",
"sqlfile" : "get_rounds"
}
23 changes: 23 additions & 0 deletions queries/get_rounds_count
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SELECT
count(*) as total_count
FROM (round r
LEFT OUTER JOIN round_type_lu rt
ON r.round_type_id=rt.round_type_id
LEFT OUTER JOIN region reg
ON r.region_id=reg.region_id
LEFT OUTER JOIN round_segment rs1
ON r.round_id=rs1.round_id and rs1.segment_id = 1
LEFT OUTER JOIN round_segment rs2
ON r.round_id=rs2.round_id and rs2.segment_id = 2
LEFT OUTER JOIN round_segment rs3
ON r.round_id=rs3.round_id and rs3.segment_id = 3
LEFT OUTER JOIN round_segment rs4
ON r.round_id=rs4.round_id and rs4.segment_id = 4
LEFT OUTER JOIN round_segment rs5
ON r.round_id=rs5.round_id and rs5.segment_id = 5
LEFT OUTER JOIN round_segment rs6
ON r.round_id=rs6.round_id and rs6.segment_id = 6
LEFT OUTER JOIN round_segment rs7
ON r.round_id=rs7.round_id and rs7.segment_id = 7
)
WHERE @filterCondition@
5 changes: 5 additions & 0 deletions queries/get_rounds_count.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_rounds_count",
"db" : "informixoltp",
"sqlfile" : "get_rounds_count"
}
9 changes: 6 additions & 3 deletions routes.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.67
* @version 1.68
* @author vangavroche, Sky_, muzehyun, kurtrips, Ghost_141, ecnu_haozi, hesibo, LazyChild, isv, flytoj2ee,
* @author panoptimum, bugbuka, Easyhard, TCASSEMBLER
*
Expand Down Expand Up @@ -154,6 +154,8 @@
* - Added get user design challenges api.
* Changed in 1.67:
* - Added get user develop challenges api.
* Changed in 1.68:
* - Added get rounds api.
*/
/*jslint node:true, nomen: true */
"use strict";
Expand Down Expand Up @@ -259,7 +261,7 @@ exports.routes = {
{ path: "/:apiVersion/develop/reviewOpportunities/:challengeId", action: "getSoftwareReviewOpportunity" },
{ path: "/:apiVersion/develop/reviewOpportunities", action: "searchReviewOpportunities" },
{ path: "/:apiVersion/develop/download/:submissionId", action: "downloadDevSubmission" },

{ path: "/:apiVersion/design/challengetypes", action: "studioTypes" },
{ path: "/:apiVersion/design/challenges/result/:challengeId", action: "getStudioChallengeResults" },
{ path: "/:apiVersion/design/reviewOpportunities/:id", action: "getStudioReviewOpportunity" },
Expand All @@ -270,7 +272,7 @@ exports.routes = {

{ path: "/:apiVersion/user/:handle/challenges/design", action: "getUserDesignChallenges" },
{ path: "/:apiVersion/user/:handle/challenges/develop", action: "getUserDevelopChallenges" },


{ path: "/:apiVersion/user/challenges", action: "getMyChallenges" },
{ path: "/:apiVersion/user/activation-email", action: "userActivationEmail" },
Expand Down Expand Up @@ -356,6 +358,7 @@ exports.routes = {
{ path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "getRoundTerms" },
{ path: "/:apiVersion/data/srm/rounds/:contestId", action: "listSRMContestRounds" },
{ path: "/:apiVersion/auth0/callback", action: "auth0Callback" },
{ path: "/:apiVersion/data/rounds", action: "getRounds" },

//Stubs APIs
{ path: "/:apiVersion/data/reviewOpportunities/:id", action: "getAlgorithmsReviewOpportunity" },
Expand Down
4 changes: 4 additions & 0 deletions test/sqls/rounds/informixoltp__clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE FROM round_terms WHERE round_id >= 12001 and round_id < 13000;
DELETE FROM round_segment WHERE round_id >= 12001 and round_id < 13000;
DELETE FROM round WHERE round_id >= 12001 and round_id < 13000;
DELETE FROM contest WHERE contest_id = 12001;
62 changes: 62 additions & 0 deletions test/sqls/rounds/informixoltp__insert_test_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
INSERT INTO contest(contest_id, name) VALUES(12001, 'test contest 12001');

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);

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');
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');
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');
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');
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');
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');
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');


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);

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');
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');
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');
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');
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');
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');
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');


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);

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');
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');
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');
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');
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');
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');
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');


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);

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');
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');
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');
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');
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');
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');
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');


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);

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');
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');
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');
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');


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);

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');
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');
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');
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');
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');
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');
Loading