]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Sort problems in standings by value and fix standings JSON
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster.pm
index ee37a4e3a8ed378fd4b9646acfb2a40384f69390..efcedf54a23e74f79fae336dfa64733b020df16d 100644 (file)
@@ -144,7 +144,10 @@ sub dispatch_request{
                sub (/st/:contest) {
                        response st => 'Standings', {
                                st => [ contest->standings ],
-                               problems => [map { $_->problem } contest->contest_problems],
+                               problems => [
+                                       map { [$_->id, $_->name] }
+                                       sort { $a->value <=> $b->value }
+                                       map { $_->problem } contest->contest_problems],
                        }, 10
                },
 
@@ -183,7 +186,7 @@ sub dispatch_request{
                                forbid !remote_user;
                                $privacy = 'private';
                        }
-                       response pb_entry => problem->name, db->problem_entry($_{problem}, $_{contest}, remote_user && remote_user->id);
+                       response pb_entry => problem->name, {%{db->problem_entry($_{problem}, $_{contest}, remote_user && remote_user->id)}, maybe contest => $_{contest}};
                },
                sub (/sol/:problem) {
                        forbid !problem->is_in_archive;
@@ -221,6 +224,7 @@ sub dispatch_request{
                        forbid !remote_user;
                        return reply 'This contest has finished' if contest && contest->is_finished;
                        return reply 'This contest has not yet started' if !admin && contest && contest->is_pending;
+                       return reply 'This problem does not belong to this contest' if !contest && !problem->is_in_archive || contest && !db->contest_problems->find($_{contest}, $_{problem});
                        return reply 'Maximum source size is 10KB' if ($prog ? $prog->size : length $_{source_code}) > 10 * 1024;
                        return reply 'You must wait 30 seconds between jobs' if !admin && time <= remote_user->lastjob + 30;
                        remote_user->update({lastjob => time});
This page took 0.024243 seconds and 4 git commands to generate.