summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Misc.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-24 09:45:02 +0100
committerYorhel <git@yorhel.nl>2010-01-24 09:45:02 +0100
commitd2dd07de4e0d9b8c00cd2db49aa2e7c0a5150bbc (patch)
tree4fc891330f8d7d513e1d22b1599880da304cdcd0 /lib/VNDB/DB/Misc.pm
parent0f35ebbfc2cb4f8da4975ded1331bb80f408ccad (diff)
Versioned the deleting and locking of database entries
This is implemented by adding ihid (item hidden) and ilock (item locked) columns to the changes table, The (vn|release|producer).(hidden|locked) columns now work as a cache, refering to the changes.(ihid|ilock) columns with changes.id = (vn|release|producer).latest. The cached columns are updated automatically each time a new revision is inserted. This is a pretty large change, bugs are quite likely.
Diffstat (limited to 'lib/VNDB/DB/Misc.pm')
-rw-r--r--lib/VNDB/DB/Misc.pm24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm
index 02df0a2b..e3ef69b1 100644
--- a/lib/VNDB/DB/Misc.pm
+++ b/lib/VNDB/DB/Misc.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
our @EXPORT = qw|
- dbStats dbItemEdit dbRevisionGet dbItemMod dbRandomQuote
+ dbStats dbItemEdit dbRevisionGet dbRandomQuote
|;
@@ -21,7 +21,7 @@ sub dbStats {
# Inserts a new revision into the database
-# Arguments: type [vrp], revision id, %options->{ editsum uid + db[item]RevisionInsert }
+# Arguments: type [vrp], revision id, %options->{ editsum uid ihid ilock + db[item]RevisionInsert }
# revision id = changes.id of the revision this edit is based on, undef to create a new DB item
# Returns: { iid, cid, rev }
sub dbItemEdit {
@@ -29,8 +29,13 @@ sub dbItemEdit {
my $fun = {qw|v vn r release p producer|}->{$type};
$self->dbExec('SELECT edit_!s_init(?)', $fun, $oid);
- $self->dbExec('UPDATE edit_revision SET requester = ?, ip = ?, comments = ?',
- $o{uid}||$self->authInfo->{id}, $self->reqIP, $o{editsum});
+ $self->dbExec('UPDATE edit_revision !H', {
+ 'requester = ?' => $o{uid}||$self->authInfo->{id},
+ 'ip = ?' => $self->reqIP,
+ 'comments = ?' => $o{editsum},
+ exists($o{ihid}) ? ('ihid = ?' => $o{ihid} ?1:0) : (),
+ exists($o{ilock}) ? ('ilock = ?' => $o{ilock}?1:0) : (),
+ });
$self->dbVNRevisionInsert( \%o) if $type eq 'v';
$self->dbProducerRevisionInsert(\%o) if $type eq 'p';
@@ -112,17 +117,6 @@ sub dbRevisionGet {
}
-# Lock or hide a DB item
-# arguments: v/r/p, id, %options ->( hidden, locked )
-sub dbItemMod {
- my($self, $type, $id, %o) = @_;
- $self->dbExec('UPDATE !s !H WHERE id = ?',
- {qw|v vn r releases p producers|}->{$type},
- { map { ($_.' = ?', int $o{$_}) } keys %o }, $id
- );
-}
-
-
# Returns a random quote (hashref with keys = vid, quote)
sub dbRandomQuote {
return $_[0]->dbRow(q|