Description:
- fix syntax error
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r599:14a14eb28fed - - 1 file changed: 1 inserted, 0 deleted
@@ -431,54 +431,55 | |||
|
431 | 431 | end |
|
432 | 432 | mark = Array.new(@sid.size,'?') |
|
433 | 433 | condition = "(u.login = " + mark.join(' OR u.login = ') + ')' |
|
434 | 434 | |
|
435 | 435 | @st = <<-SQL |
|
436 | 436 | SELECT l.created_at as submitted_at ,-1 as id,u.login,u.full_name,l.ip_address,"" as problem_id,"" as points,l.user_id |
|
437 | 437 | FROM logins l INNER JOIN users u on l.user_id = u.id |
|
438 | 438 | WHERE l.created_at >= ? AND l.created_at <= ? AND #{condition} |
|
439 | 439 | UNION |
|
440 | 440 | SELECT s.submitted_at,s.id,u.login,u.full_name,s.ip_address,s.problem_id,s.points,s.user_id |
|
441 | 441 | FROM submissions s INNER JOIN users u ON s.user_id = u.id |
|
442 | 442 | WHERE s.submitted_at >= ? AND s.submitted_at <= ? AND #{condition} |
|
443 | 443 | ORDER BY submitted_at |
|
444 | 444 | SQL |
|
445 | 445 | |
|
446 | 446 | p = [@st,@since_time,@until_time] + @sid + [@since_time,@until_time] + @sid |
|
447 | 447 | @logs = Submission.joins(:problem).find_by_sql(p) |
|
448 | 448 | |
|
449 | 449 | |
|
450 | 450 | |
|
451 | 451 | |
|
452 | 452 | |
|
453 | 453 | end |
|
454 | 454 | |
|
455 | 455 | protected |
|
456 | 456 | |
|
457 | 457 | def calculate_max_score(problems, users,since_id,until_id, get_last_score = false) |
|
458 | 458 | scorearray = Array.new |
|
459 | 459 | users.each do |u| |
|
460 | 460 | ustat = Array.new |
|
461 | 461 | ustat[0] = u |
|
462 | 462 | problems.each do |p| |
|
463 | 463 | unless get_last_score |
|
464 | 464 | #get max score |
|
465 | 465 | max_points = 0 |
|
466 | 466 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
467 | 467 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
468 | 468 | end |
|
469 | 469 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
470 | 470 | else |
|
471 | 471 | #get latest score |
|
472 | 472 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
473 | 473 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
474 | 474 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
475 | 475 | else |
|
476 | 476 | ustat << [0,false] |
|
477 | 477 | end |
|
478 | 478 | end |
|
479 | + end | |
|
479 | 480 | scorearray << ustat |
|
480 | 481 | end |
|
481 | 482 | return scorearray |
|
482 | 483 | end |
|
483 | 484 | |
|
484 | 485 | end |
You need to be logged in to leave comments.
Login now