diff options
author | Yorhel <git@yorhel.nl> | 2015-10-17 17:05:50 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-10-17 17:20:41 +0200 |
commit | 718f4d0258049aa92f229c08d5ec7204dae3ffa6 (patch) | |
tree | fc45906cbc145e85e7954671da10d7dbbab9dfbc /lib/VNDB/Handler/Staff.pm | |
parent | eed1eced579e022135f98f3f733ecab88e3b6b6e (diff) |
SQL: Fix all browsing queries to use the new schema
This basically makes VNDB browsable again, but editing entries is still
broken.
I split off the get-old-revision functionality from the db*Get() methods
into db*GetRev(). This split makes sense even with the old SQL schema:
db*Get() had to special-case some joins/filters when fetching an older
revision, and none of the other filters would work in that case. This
split does cause some code duplication in that all db*GetRev() methods
look very much alike, and that the columns they fetch is almost
identical to the db*Get() methods. Not sure yet how to avoid the
duplication elegantly.
I didn't do a whole lot of query optimization yet (most issues require
extra indices, I'll investigate later which indices will make a big
difference), but I did fix some low hanging fruit whenever I encountered
something.
I don't think I've worsened anything, performance-wise.
Diffstat (limited to 'lib/VNDB/Handler/Staff.pm')
-rw-r--r-- | lib/VNDB/Handler/Staff.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm index 88e6d7c8..f2e855ba 100644 --- a/lib/VNDB/Handler/Staff.pm +++ b/lib/VNDB/Handler/Staff.pm @@ -19,9 +19,10 @@ TUWF::register( sub page { my($self, $id, $rev) = @_; - my $s = $self->dbStaffGet( + my $method = $rev ? 'dbStaffGetRev' : 'dbStaffGet'; + my $s = $self->$method( id => $id, - what => 'extended aliases roles'.($rev ? ' changes' : ''), + what => 'extended aliases roles', $rev ? ( rev => $rev ) : () )->[0]; return $self->resNotFound if !$s->{id}; @@ -31,7 +32,7 @@ sub page { return if $self->htmlHiddenMessage('s', $s); if($rev) { - my $prev = $rev && $rev > 1 && $self->dbStaffGet(id => $id, rev => $rev-1, what => 'changes extended aliases')->[0]; + my $prev = $rev && $rev > 1 && $self->dbStaffGetRev(id => $id, rev => $rev-1, what => 'extended aliases')->[0]; $self->htmlRevision('s', $prev, $s, [ name => diff => 1 ], [ original => diff => 1 ], @@ -179,9 +180,9 @@ sub _cast { sub edit { my($self, $sid, $rev) = @_; - my $s = $sid && $self->dbStaffGet(id => $sid, what => 'changes extended aliases', $rev ? (rev => $rev) : ())->[0]; + my $s = $sid && $self->dbStaffGetRev(id => $sid, what => 'extended aliases', $rev ? (rev => $rev) : ())->[0]; return $self->resNotFound if $sid && !$s->{id}; - $rev = undef if !$s || $s->{cid} == $s->{latest}; + $rev = undef if !$s || $s->{lastrev}; return $self->htmlDenied if !$self->authCan('staffedit') || $sid && (($s->{locked} || $s->{hidden}) && !$self->authCan('dbmod')); @@ -384,4 +385,3 @@ sub staffxml { } 1; -__END__ |