File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
1
node_modules /
2
2
package-lock.json
3
3
.DS_Store
4
- dist /
4
+ dist /
5
+ secrets.json
Original file line number Diff line number Diff line change
1
+ const axios = require ( "axios" ) ;
2
+ const { kaggleUsername, kaggleApiKey } = require ( "../../secrets.json" ) ;
3
+ const { parserErrorHandler, getCurrentTimeInSeconds } = require ( './../utils' ) ;
4
+
5
+ const KAGGLE_API_URL = "https://www.kaggle.com/api/v1/competitions/list" ;
6
+ const KAGGLE = 'kaggle' ;
7
+
8
+ const isContestActive = ( currentTimeInSeconds ) => contest => contest . endTime > currentTimeInSeconds
9
+
10
+ const convertToStandardContest = contest => ( {
11
+ name : contest . title ,
12
+ url : contest . url ,
13
+ platform : KAGGLE ,
14
+ startTime : Date . parse ( contest . enabledDate ) / 1000 ,
15
+ endTime : Date . parse ( contest . deadline ) / 1000 ,
16
+ } ) ;
17
+
18
+ const kaggle = ( ) => axios . get ( KAGGLE_API_URL , {
19
+ timeout : 15000 ,
20
+ auth : {
21
+ username : kaggleUsername ,
22
+ password : kaggleApiKey ,
23
+ } ,
24
+ } )
25
+ . then ( response => response . data
26
+ . map ( convertToStandardContest )
27
+ . filter ( isContestActive ( getCurrentTimeInSeconds ( ) ) )
28
+ )
29
+ . catch ( parserErrorHandler ( KAGGLE ) ) ;
30
+
31
+ module . exports = kaggle ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const codechef = require('./parsers/codechef');
11
11
const atcoder = require ( './parsers/atcoder' ) ;
12
12
const csacademy = require ( './parsers/csacademy' ) ;
13
13
const coj = require ( './parsers/coj' ) ;
14
+ const kaggle = require ( './parsers/kaggle' ) ;
14
15
15
16
const runner = ( ) => axios . all ( [
16
17
codeforces ( ) ,
@@ -22,6 +23,7 @@ const runner = () => axios.all([
22
23
atcoder ( ) ,
23
24
csacademy ( ) ,
24
25
coj ( ) ,
26
+ kaggle ( ) ,
25
27
] )
26
28
. then ( ( contestsByPlatform ) => {
27
29
const contests = flat ( contestsByPlatform . filter ( it => Array . isArray ( it ) ) ) ;
You can’t perform that action at this time.
0 commit comments