@@ -304,7 +304,7 @@ impl LeetCode<Authorized> {
304304
305305 let interpret_id = data. interpret_id ;
306306 println ! ( "Executing testcases..." ) ;
307- let mut last_state = 0 ;
307+ let mut last_state = PendingState :: Unknown ;
308308 loop {
309309 let url = format ! ( "https://leetcode.com/submissions/detail/{interpret_id}/check/" ) ;
310310 // std::thread::sleep(std::time::Duration::from_secs(7));
@@ -317,29 +317,32 @@ impl LeetCode<Authorized> {
317317 } ;
318318 match data {
319319 ExecutionResult :: PendingResult ( data) => {
320- last_state = match data. state . as_str ( ) {
321- "PENDING" => {
322- if last_state == 0 {
323- println ! ( "Status : Pending" ) ;
320+ let curr_state = data. state ( ) ;
321+ match curr_state {
322+ PendingState :: Pending => {
323+ if last_state != PendingState :: Pending {
324+ println ! ( "Status : Evalutaion Pending" ) ;
324325 }
325- 1
326326 }
327- "STARTED" => {
328- if last_state == 1 {
327+ PendingState :: Started => {
328+ if last_state != PendingState :: Started {
329329 println ! ( "Status : Execution Started" ) ;
330330 }
331- 2
332331 }
333- _ => {
334- if last_state == 2 {
335- println ! (
336- "Status : {}\n Kindly report this state to developer" ,
337- data. state. as_str( )
338- ) ;
339- }
340- 3
332+ PendingState :: Success => {
333+ println ! ( "Your code was executed successfully but we failed to parse result\n Check on leetcode manually" ) ;
334+ std:: process:: exit ( 1 ) ;
335+ }
336+ PendingState :: Unknown => {
337+ println ! (
338+ "Status : {}\n Kindly report this state to developer" ,
339+ data. state. as_str( )
340+ ) ;
341+ std:: process:: exit ( 1 ) ;
341342 }
342343 } ;
344+ last_state = curr_state;
345+
343346 continue ;
344347 }
345348 data => return Ok ( data) ,
@@ -385,7 +388,7 @@ impl LeetCode<Authorized> {
385388 } ;
386389 println ! ( "Evaluating solution..." ) ;
387390 let submission_id = data. submission_id ;
388- let mut last_state = 0 ;
391+ let mut last_state = PendingState :: Unknown ;
389392
390393 loop {
391394 let url = format ! ( "https://leetcode.com/submissions/detail/{submission_id}/check/" ) ;
@@ -398,29 +401,31 @@ impl LeetCode<Authorized> {
398401 } ;
399402 match data {
400403 SubmissionResult :: PendingResult ( data) => {
401- last_state = match data. state . as_str ( ) {
402- "PENDING" => {
403- if last_state == 0 {
404+ let curr_state = data. state ( ) ;
405+ match curr_state {
406+ PendingState :: Pending => {
407+ if last_state != PendingState :: Pending {
404408 println ! ( "Status : Evalutaion Pending" ) ;
405409 }
406- 1
407410 }
408- "STARTED" => {
409- if last_state == 1 {
411+ PendingState :: Started => {
412+ if last_state != PendingState :: Started {
410413 println ! ( "Status : Execution Started" ) ;
411414 }
412- 2
413415 }
414- _ => {
415- if last_state == 2 {
416- println ! (
417- "Status : {}\n Kindly report this state to developer" ,
418- data. state. as_str( )
419- ) ;
420- }
421- 3
416+ PendingState :: Success => {
417+ println ! ( "Your code was executed successfully but we failed to parse result\n Check on leetcode manually" ) ;
418+ std:: process:: exit ( 1 ) ;
419+ }
420+ PendingState :: Unknown => {
421+ println ! (
422+ "Status : {}\n Kindly report this state to developer" ,
423+ data. state. as_str( )
424+ ) ;
425+ std:: process:: exit ( 1 ) ;
422426 }
423427 } ;
428+ last_state = curr_state;
424429 continue ;
425430 }
426431 data => return Ok ( data) ,
0 commit comments