File tree Expand file tree Collapse file tree 1 file changed +9
-28
lines changed Expand file tree Collapse file tree 1 file changed +9
-28
lines changed Original file line number Diff line number Diff line change @@ -273,14 +273,14 @@ export default class Problems extends React.PureComponent {
273
273
this . fetchactions ( )
274
274
}
275
275
276
- fetchproblems ( ) {
276
+ fetchproblems ( problems ) {
277
277
// console.log("Fetching problems", problems);
278
278
var probs = [ ]
279
279
var noftests = [ ]
280
280
var allinputs = { }
281
281
var alloutputs = { }
282
282
var allverdicts = { }
283
- for ( var problem of this . state . probs ) {
283
+ for ( var problem of problems ) {
284
284
probs . push ( {
285
285
index : problem . index ,
286
286
name : problem . name ,
@@ -366,33 +366,14 @@ export default class Problems extends React.PureComponent {
366
366
. catch ( err => console . log ( err ) )
367
367
}
368
368
369
- scrapeproblems ( html ) {
370
- if ( html == null ) return
371
- $ = cheerio . load ( html )
372
- var i = 2
373
- var probs = [ ]
374
- while ( true ) {
375
- var idx = $ ( `#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child(${ i } ) > td.id > a` ) . text ( ) . trim ( )
376
- var nm = $ ( `#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child(${ i } ) > td:nth-child(2) > div > div:nth-child(1) > a` ) . text ( ) . trim ( )
377
- if ( idx . length == 0 ) {
378
- break ;
379
- } else {
380
- probs . push ( { index : idx , name : nm } )
381
- }
382
- i ++ ;
383
- }
384
-
385
- this . setState ( { probs : probs } )
386
- }
387
-
388
369
componentWillMount ( ) {
389
- var url = "https://codeforces.com/contest/ " + this . props . contest . id
390
- this . fetch ( url ) . then ( html => {
391
- this . scrapeproblems ( html ) ;
392
- } ) . then ( res => {
393
- this . fetchproblems ( )
394
- } ) . catch ( ( error ) => {
395
- atom . notifications . addWarning ( "Error in fetching problems" )
370
+ var url = "https://codeforces.com/api/contest.standings?contestId= " + this . props . contest . id + "&from=1&count=1"
371
+ fetch ( url )
372
+ . then ( res => res . json ( ) )
373
+ . then ( res => this . fetchproblems ( res . result . problems ) )
374
+ . catch ( err => {
375
+ console . log ( err )
376
+ atom . notifications . addWarning ( "Error while fetching problems" )
396
377
} )
397
378
398
379
var intervaltime = atom . config . get ( "codeblue.refreshinterval" )
You can’t perform that action at this time.
0 commit comments