From 4e3081f530526601d82fbe792ea4c0f9bc9a9c9a Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 29 Sep 2018 12:51:54 +0200 Subject: Add default spoiler level to tags and use it in spoiler calculation https://vndb.org/t11296.3 (And I forgot to add update_20180929.sql in the previous commit) --- lib/VNDB/DB/Tags.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/VNDB/DB') diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index 8c27e55f..fb4717d8 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -39,7 +39,7 @@ sub dbTagGet { 't.meta = ?' => $o{meta}?1:0 ) : (), ); my @select = ( - qw|t.id t.meta t.name t.description t.state t.cat t.c_items|, + qw|t.id t.meta t.name t.description t.state t.cat t.c_items t.defaultspoil|, q|extract('epoch' from t.added) as added|, $o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (), ); @@ -129,7 +129,7 @@ sub dbTagEdit { $self->dbExec('UPDATE tags !H WHERE id = ?', { $o{upddate} ? ('added = NOW()' => 1) : (), - map exists($o{$_}) ? ("$_ = ?" => $o{$_}) : (), qw|name meta description state cat| + map exists($o{$_}) ? ("$_ = ?" => $o{$_}) : (), qw|name meta description state cat defaultspoil| }, $id); if($o{aliases}) { $self->dbExec('DELETE FROM tags_aliases WHERE tag = ?', $id); @@ -147,8 +147,8 @@ sub dbTagEdit { # returns the id of the new tag sub dbTagAdd { my($self, %o) = @_; - my $id = $self->dbRow('INSERT INTO tags (name, meta, description, state, cat, addedby) VALUES (!l, ?) RETURNING id', - [ map $o{$_}, qw|name meta description state cat| ], $o{addedby}||$self->authInfo->{id} + my $id = $self->dbRow('INSERT INTO tags (name, meta, description, state, cat, defaultspoil, addedby) VALUES (!l, ?) RETURNING id', + [ map $o{$_}, qw|name meta description state cat defaultspoil| ], $o{addedby}||$self->authInfo->{id} )->{id}; $self->dbExec('INSERT INTO tags_parents (tag, parent) VALUES (?, ?)', $id, $_) for(@{$o{parents}}); $self->dbExec('INSERT INTO tags_aliases (tag, alias) VALUES (?, ?)', $id, $_) for (@{$o{aliases}}); @@ -257,7 +257,7 @@ sub dbTagStats { my($r, $np) = $self->dbPage(\%o, qq| SELECT t.id, t.name, t.cat, count(*) as cnt, $rating as rating, - COALESCE(avg(CASE WHEN tv.ignore THEN NULL ELSE tv.spoiler END), 0) as spoiler, + COALESCE(avg(CASE WHEN tv.ignore THEN NULL ELSE tv.spoiler END), t.defaultspoil) as spoiler, bool_or(tv.ignore) AS overruled FROM tags t JOIN tags_vn tv ON tv.tag = t.id -- cgit v1.2.3