@@ -148,9 +148,10 @@ class submission {
148
148
expected_output : Buffer . from ( current . expectedOutput , "binary" ) . toString (
149
149
"base64" ,
150
150
) ,
151
- cpu_time_limit : current . time * multipler < 15
152
- ? current . time * multipler
153
- : 15 ,
151
+ cpu_time_limit :
152
+ current . time * multipler < 15 ? current . time * multipler : 15 ,
153
+ memory :
154
+ current . memory * multipler < 2048 ? 2048 : current . memory * multipler
154
155
//redirect_stderr_to_stdout: true,
155
156
} ) ;
156
157
const group = current . group ;
@@ -198,7 +199,7 @@ class submission {
198
199
"/submissions/batch?tokens=" +
199
200
str . toString ( ) +
200
201
"&base64_encoded=true&fields=status_id,stderr,compile_output,expected_output,stdout,time" ;
201
- console . log ( url ) ;
202
+ // console.log(url);
202
203
let completion = false ;
203
204
let data_sent_back = {
204
205
error : [ false , false , false , false ] , //false means it passed that grp
@@ -308,10 +309,9 @@ class submission {
308
309
} ) ;
309
310
310
311
//comparing the score with the existing score and picking the best one
311
- data_sent_back . Score = ! check || score >= check . score
312
- ? score
313
- : check . score ;
314
- console . log ( data_sent_back . Score , score ) ;
312
+ data_sent_back . Score =
313
+ ! check || score >= check . score ? score : check . score ;
314
+ //console.log(data_sent_back.Score, score);
315
315
316
316
//If new score is higher or equal to the existing score, then sub DB is updated
317
317
if ( data_sent_back . Score == score ) {
@@ -326,6 +326,7 @@ class submission {
326
326
await this . create_score ( reg_no ) ;
327
327
} else {
328
328
data_sent_back . Sub_db = "No changes in Sub DB" ;
329
+ await this . create_score ( reg_no ) ;
329
330
}
330
331
331
332
//Creation of allPassesAt field when all testcases are passed
@@ -366,8 +367,7 @@ class submission {
366
367
] ) ;
367
368
const score = ele [ 0 ] . total ;
368
369
return User . updateOne ( { regNo : user } , { score : score } )
369
- . then ( ( ) => console . log ( "Score = " + score ) )
370
- . catch ( ( ) => console . error ( "Error occured while saving scores" ) ) ;
370
+ . catch ( ( ) => console . error ( "Error occured while saving scores \nRegno :" + regNo + "\tScore :" + score ) ) ;
371
371
}
372
372
373
373
async get_reg_no ( req , res ) {
@@ -394,12 +394,12 @@ class submission {
394
394
395
395
async get_all ( req , res ) {
396
396
const { regno } = req . params ;
397
- console . log ( regno ) ;
397
+ // console.log(regno);
398
398
const record = await submission_db . find (
399
399
{ regNo : regno } ,
400
400
"code score question_id lastResults language_id" ,
401
401
) ;
402
- console . log ( record ) ;
402
+ // console.log(record);
403
403
if ( record . length == 0 ) {
404
404
res . status ( 400 ) . json ( {
405
405
Error : "Invalid regNo" ,
@@ -485,12 +485,12 @@ class submission {
485
485
let items = Object . keys ( leaderboard ) . map ( function ( key ) {
486
486
return [ key , leaderboard [ key ] ] ;
487
487
} ) ;
488
- items . sort ( function ( a , b ) {
489
- console . log ( a [ 1 ] [ 0 ] ) ;
490
- if ( a [ 1 ] [ 0 ] > b [ 1 ] [ 0 ] ) return - 1 ;
491
- if ( a [ 1 ] [ 0 ] < b [ 1 ] [ 0 ] ) return 1 ;
492
- if ( a [ 1 ] [ 1 ] > b [ 1 ] [ 1 ] ) return 1 ;
493
- if ( a [ 1 ] [ 1 ] < b [ 1 ] [ 1 ] ) return - 1 ;
488
+ items . sort ( function ( a , b ) {
489
+ // console.log(a[1][0]);
490
+ if ( a [ 1 ] [ 0 ] > b [ 1 ] [ 0 ] ) return - 1 ;
491
+ if ( a [ 1 ] [ 0 ] < b [ 1 ] [ 0 ] ) return 1 ;
492
+ if ( a [ 1 ] [ 1 ] > b [ 1 ] [ 1 ] ) return 1 ;
493
+ if ( a [ 1 ] [ 1 ] < b [ 1 ] [ 1 ] ) return - 1 ;
494
494
} ) ;
495
495
res . status ( 200 ) . json ( items ) ;
496
496
}
0 commit comments