@@ -16,20 +16,7 @@ var upload = multer({dest:'solutions/'})
1616var originalname = 'solution' ;
1717router . post ( '/' , upload . single ( originalname ) , async ( req , res ) => {
1818 var solution ;
19-
20- if ( ! req . file ) {
21- var count = await Solution . getObjCount ( req . body . username , req . body . contest , req . body . problem ) + 1 ;
22- solution = new Solution ( {
23- problem :req . body . problem ,
24- contest :req . body . contest ,
25- username :req . body . username ,
26- id :req . body . contest + req . body . problem + req . body . username + count ,
27- language :req . body . language . toLowerCase ( ) ,
28- description :req . body . description . toString ( 'base64' ) ,
29- submitted_on :new Date ( )
30- } ) ;
31- }
32- else if ( req . file ) {
19+ if ( req . file ) {
3320 var count = await Solution . getObjCount ( req . body . username , req . body . contest , req . body . problem ) + 1 ;
3421 solution = new Solution ( {
3522 problem :req . body . problem ,
@@ -41,6 +28,19 @@ router.post('/',upload.single(originalname),async (req,res)=>{
4128 submitted_on :new Date ( )
4229 } ) ;
4330 }
31+
32+ else if ( ! req . file ) {
33+ var count = await Solution . getObjCount ( req . body . username , req . body . contest , req . body . problem ) + 1 ;
34+ solution = new Solution ( {
35+ problem :req . body . problem ,
36+ contest :req . body . contest ,
37+ username :req . body . username ,
38+ id :req . body . contest + req . body . problem + req . body . username + count ,
39+ language :req . body . language . toLowerCase ( ) ,
40+ description :req . body . description . toString ( 'base64' ) ,
41+ submitted_on :new Date ( )
42+ } ) ;
43+ }
4444
4545 solution . save ( ) . then ( ( sol ) => {
4646 const agentOptions = new Object ( ) ;
0 commit comments