summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Tags.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-09-29 12:51:54 +0200
committerYorhel <git@yorhel.nl>2018-09-29 12:52:47 +0200
commit4e3081f530526601d82fbe792ea4c0f9bc9a9c9a (patch)
tree44eeb9323c7e1af549c5dfa6f540e9c37ef90a0a /lib/VNDB/DB/Tags.pm
parent706f447961d18c36ffdc6be34a6eae40acd01574 (diff)
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)
Diffstat (limited to 'lib/VNDB/DB/Tags.pm')
-rw-r--r--lib/VNDB/DB/Tags.pm10
1 files changed, 5 insertions, 5 deletions
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