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/Chars.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/Chars.pm')
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 7171d506..524b5a04 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -20,9 +20,10 @@ TUWF::register( sub page { my($self, $id, $rev) = @_; - my $r = $self->dbCharGet( + my $method = $rev ? 'dbCharGetRev' : 'dbCharGet'; + my $r = $self->$method( id => $id, - what => 'extended traits vns seiyuu'.($rev ? ' changes' : ''), + what => 'extended traits vns seiyuu', $rev ? ( rev => $rev ) : () )->[0]; return $self->resNotFound if !$r->{id}; @@ -32,7 +33,7 @@ sub page { return if $self->htmlHiddenMessage('c', $r); if($rev) { - my $prev = $rev && $rev > 1 && $self->dbCharGet(id => $id, rev => $rev-1, what => 'changes extended traits vns')->[0]; + my $prev = $rev && $rev > 1 && $self->dbCharGetRev(id => $id, rev => $rev-1, what => 'extended traits vns')->[0]; $self->htmlRevision('c', $prev, $r, [ name => diff => 1 ], [ original => diff => 1 ], @@ -265,9 +266,9 @@ sub edit { $copy = $rev && $rev eq 'copy' || $copy && $copy eq 'copy'; $rev = undef if defined $rev && $rev !~ /^\d+$/; - my $r = $id && $self->dbCharGet(id => $id, what => 'changes extended vns traits', $rev ? (rev => $rev) : ())->[0]; + my $r = $id && $self->dbCharGetRev(id => $id, what => 'extended vns traits', $rev ? (rev => $rev) : ())->[0]; return $self->resNotFound if $id && !$r->{id}; - $rev = undef if !$r || $r->{cid} == $r->{latest}; + $rev = undef if !$r || $r->{lastrev}; return $self->htmlDenied if !$self->authCan('edit') || $id && (($r->{locked} || $r->{hidden}) && !$self->authCan('dbmod')); |