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 {
273273 this . fetchactions ( )
274274 }
275275
276- fetchproblems ( ) {
276+ fetchproblems ( problems ) {
277277 // console.log("Fetching problems", problems);
278278 var probs = [ ]
279279 var noftests = [ ]
280280 var allinputs = { }
281281 var alloutputs = { }
282282 var allverdicts = { }
283- for ( var problem of this . state . probs ) {
283+ for ( var problem of problems ) {
284284 probs . push ( {
285285 index : problem . index ,
286286 name : problem . name ,
@@ -366,33 +366,14 @@ export default class Problems extends React.PureComponent {
366366 . catch ( err => console . log ( err ) )
367367 }
368368
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-
388369 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" )
396377 } )
397378
398379 var intervaltime = atom . config . get ( "codeblue.refreshinterval" )
You can’t perform that action at this time.
0 commit comments