projects
/
gruntmaster-page.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
491e82e
)
From Redis to Postgres - Part 3 (Bugfixes, first try)
author
Marius Gavrilescu
<marius@ieval.ro>
Wed, 19 Mar 2014 16:28:52 +0000
(18:28 +0200)
committer
Marius Gavrilescu
<marius@ieval.ro>
Wed, 19 Mar 2014 16:29:14 +0000
(18:29 +0200)
app.psgi
patch
|
blob
|
blame
|
history
lib/Gruntmaster/Page/Generic.pm
patch
|
blob
|
blame
|
history
lib/Gruntmaster/Page/Src.pm
patch
|
blob
|
blame
|
history
lib/Gruntmaster/Page/St.pm
patch
|
blob
|
blame
|
history
lib/Plack/App/Gruntmaster.pm
patch
|
blob
|
blame
|
history
diff --git
a/app.psgi
b/app.psgi
index 2e3f6405c7b7848c5ee1e8ffde433430f92e2260..e662e264184bbf6c93705e9105895590e38014f0 100644
(file)
--- a/
app.psgi
+++ b/
app.psgi
@@
-61,6
+61,7
@@
sub mangle_request {
$env->{'gruntmaster.problem'} = $1 if s,^/pb/$word/,/,;
$env->{'gruntmaster.contest'} = $1 if s,^/ct/$word/,/,;
$env->{'gruntmaster.user'} = $1 if s,^/us/$word/,/,;
$env->{'gruntmaster.problem'} = $1 if s,^/pb/$word/,/,;
$env->{'gruntmaster.contest'} = $1 if s,^/ct/$word/,/,;
$env->{'gruntmaster.user'} = $1 if s,^/us/$word/,/,;
+ $env->{'gruntmaster.page'} //= -1 if m,^/log/$,;
}
$app->($env);
}
}
$app->($env);
}
diff --git
a/lib/Gruntmaster/Page/Generic.pm
b/lib/Gruntmaster/Page/Generic.pm
index 256add635bed2a31ed85d929cab7e710722ea57f..10ed5568e6831b88ea43d0da93b27956dab7016c 100644
(file)
--- a/
lib/Gruntmaster/Page/Generic.pm
+++ b/
lib/Gruntmaster/Page/Generic.pm
@@
-37,6
+37,7
@@
sub list {
$rs = $rs->search(undef, {order_by => 'me.id'}) unless $rs->is_ordered;
if (my $page = $env->{'gruntmaster.page'}) {
my $pages = $rs->count / PAGE_SIZE;
$rs = $rs->search(undef, {order_by => 'me.id'}) unless $rs->is_ordered;
if (my $page = $env->{'gruntmaster.page'}) {
my $pages = $rs->count / PAGE_SIZE;
+ $page = $pages if $page == -1;
$rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))});
}
$rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch};
$rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))});
}
$rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch};
diff --git
a/lib/Gruntmaster/Page/Src.pm
b/lib/Gruntmaster/Page/Src.pm
index e54e79f9840508f0cb696de534054fd765db511c..4fc2550dc9b2d9c0fcc2889a9331409e74d78301 100644
(file)
--- a/
lib/Gruntmaster/Page/Src.pm
+++ b/
lib/Gruntmaster/Page/Src.pm
@@
-13,8
+13,8
@@
use constant CONTENT_TYPES => +{
};
sub generate{
};
sub generate{
- my ($self, $format, $env, $
ct, $
job, $ext) = @_;
- debug $env => "
Contest is $ct, j
ob is $job and extension is $ext";
+ my ($self, $format, $env, $job, $ext) = @_;
+ debug $env => "
J
ob is $job and extension is $ext";
[200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800', 'X-Forever' => 1], [db($env)->job($job)->source] ]
}
[200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800', 'X-Forever' => 1], [db($env)->job($job)->source] ]
}
diff --git
a/lib/Gruntmaster/Page/St.pm
b/lib/Gruntmaster/Page/St.pm
index 2d7b23831f29cb08420ae5d04f90dc1b9d07279c..547eaba544297c8ea7d49947558e9c90ee8a2b5d 100644
(file)
--- a/
lib/Gruntmaster/Page/St.pm
+++ b/
lib/Gruntmaster/Page/St.pm
@@
-21,14
+21,14
@@
sub calc_score{
}
sub _generate{
}
sub _generate{
- my ($self, $htc, $lang, $env
, $ct
) = @_;
-
debug $env => "language is '$lang' and contest is '$ct
'";
+ my ($self, $htc, $lang, $env) = @_;
+
#debug $env => "language is '$lang
'";
-
$ct &&= db($env)->contest($ct
);
+
my $ct = $env->{'gruntmaster.contest'} && db($env)->contest($env->{'gruntmaster.contest'}
);
- my @problems = map { $_->problem } db($env)->contest_problems->search({contest => $ct->id}, {qw/join problem order_by problem.level/});
+ my @problems = map { $_->problem } db($env)->contest_problems->search({contest => $ct
&& $ct
->id}, {qw/join problem order_by problem.level/});
my (%scores, %tries);
my (%scores, %tries);
- for my $job (db($env)->jobs->search({contest => $ct->id})) {
+ for my $job (db($env)->jobs->search({contest => $ct
&& $ct
->id})) {
if ($ct) {
my $time = $job->date - $ct->start;
if ($ct) {
my $time = $job->date - $ct->start;
@@
-42,7
+42,7
@@
sub _generate{
}
}
}
}
- my @st = sort { $b->{score} <=> $a->{score} or $a->{user}
cmp $b->{user}
} map {
+ my @st = sort { $b->{score} <=> $a->{score} or $a->{user}
->id cmp $b->{user}->id
} map {
my $user = $_;
+{
user => db($env)->user($user),
my $user = $_;
+{
user => db($env)->user($user),
diff --git
a/lib/Plack/App/Gruntmaster.pm
b/lib/Plack/App/Gruntmaster.pm
index 5b5f6606a25507f9f105faaff4586895ce48e335..8d828c0963d27de49f6f9fd05a6e884dfd9eb013 100644
(file)
--- a/
lib/Plack/App/Gruntmaster.pm
+++ b/
lib/Plack/App/Gruntmaster.pm
@@
-75,9
+75,9
@@
BEGIN{
get qr,/css/$word\.css, => 'CSS';
get qr,/js\.js, => 'JS';
get qr,/css/$word\.css, => 'CSS';
get qr,/js\.js, => 'JS';
+ get qr,/log/st, => 'St';
generic qw/us ct pb log/;
generic qw/us ct pb log/;
- get qr,/log/st, => 'St';
get qr,/log/src/$number\.$word, => 'Src';
post qr,/pb/$word/submit, => 'Submit';
get qr,/log/src/$number\.$word, => 'Src';
post qr,/pb/$word/submit, => 'Submit';
This page took
0.013512 seconds
and
4
git commands to generate.