diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNWeb/TT/TagLinks.pm | 14 | ||||
-rw-r--r-- | lib/VNWeb/VN/Tagmod.pm | 15 |
2 files changed, 18 insertions, 11 deletions
diff --git a/lib/VNWeb/TT/TagLinks.pm b/lib/VNWeb/TT/TagLinks.pm index efe3e8b2..6674d383 100644 --- a/lib/VNWeb/TT/TagLinks.pm +++ b/lib/VNWeb/TT/TagLinks.pm @@ -16,8 +16,9 @@ sub listing_ { td_ class => 'tc3', 'Rating'; td_ class => 'tc4', sub { txt_ 'Tag'; sortable_ 'tag', $opt, $url }; td_ class => 'tc5', 'Spoiler'; - td_ class => 'tc6', 'Visual novel'; - td_ class => 'tc7', 'Note'; + td_ class => 'tc6', 'Lie'; + td_ class => 'tc7', 'Visual novel'; + td_ class => 'tc8', 'Note'; }}; tr_ sub { my $i = $_; @@ -32,15 +33,20 @@ sub listing_ { a_ href => "/$i->{tag}", $i->{name}; }; td_ class => 'tc5', sub { - my $s = !defined $i->{spoiler} ? '' : $i->{lie} ? 'False' : fmtspoil $i->{spoiler}; + my $s = !defined $i->{spoiler} ? '' : fmtspoil $i->{spoiler}; b_ class => 'grayedout', $s if $i->{ignore}; txt_ $s if !$i->{ignore}; }; td_ class => 'tc6', sub { + my $s = !defined $i->{lie} ? '' : $i->{lie} ? '+' : '-'; + b_ class => 'grayedout', $s if $i->{ignore}; + txt_ $s if !$i->{ignore}; + }; + td_ class => 'tc7', sub { a_ href => $url->(v => $i->{vid}, p=>undef), title => $i->{alttitle}||$i->{title}, class => 'setfil', '> ' if !defined $opt->{v}; a_ href => "/$i->{vid}", title => $i->{alttitle}||$i->{title}, shorten $i->{title}, 50; }; - td_ class => 'tc7', sub { lit_ bb_format $i->{notes}, inline => 1 }; + td_ class => 'tc8', sub { lit_ bb_format $i->{notes}, inline => 1 }; } for @$lst; }; }; diff --git a/lib/VNWeb/VN/Tagmod.pm b/lib/VNWeb/VN/Tagmod.pm index a20d96ad..2555fa08 100644 --- a/lib/VNWeb/VN/Tagmod.pm +++ b/lib/VNWeb/VN/Tagmod.pm @@ -9,7 +9,8 @@ my $FORM = { tags => { sort_keys => 'id', aoh => { id => { vndbid => 'g' }, vote => { int => 1, enum => [ -3..3 ] }, - spoil => { required => 0, uint => 1, enum => [ 0..3 ] }, + spoil => { required => 0, uint => 1, enum => [ 0..2 ] }, + lie => { undefbool => 1 }, overrule => { anybool => 1 }, notes => { required => 0, default => '', maxlength => 1000 }, cat => { _when => 'out' }, @@ -17,6 +18,7 @@ my $FORM = { rating => { _when => 'out', num => 1 }, count => { _when => 'out', uint => 1 }, spoiler => { _when => 'out', num => 1 }, + islie => { _when => 'out', anybool => 1 }, overruled => { _when => 'out', anybool => 1 }, othnotes => { _when => 'out' }, hidden => { _when => 'out', anybool => 1 }, @@ -58,9 +60,7 @@ elm_api Tagmod => $FORM_OUT, $FORM_IN, sub { # Add & update tags for(@$tags) { my $row = { uid => auth->uid, vid => $id, tag => $_->{id}, vote => $_->{vote}, notes => $_->{notes} - , spoiler => !defined $_->{spoil} ? undef : $_->{spoil} == 3 ? 0 : $_->{spoil} - , lie => !defined $_->{spoil} ? undef : $_->{spoil} == 3 ? 1 : 0 - , ignore => ($_->{overruled} && !$_->{overrule})?1:0 + , spoiler => $_->{spoil}, lie => $_->{lie}, ignore => ($_->{overruled} && !$_->{overrule})?1:0 }; tuwf->dbExeci('INSERT INTO tags_vn', $row, 'ON CONFLICT (uid, tag, vid) DO UPDATE SET', $row); tuwf->dbExeci('UPDATE tags_vn SET ignore = TRUE WHERE uid IS DISTINCT FROM (', \auth->uid, ') AND vid =', \$id, 'AND tag =', \$_->{id}) if $_->{overrule}; @@ -83,8 +83,8 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub { my $tags = tuwf->dbAlli(' SELECT t.id, t.name, t.cat, count(*) as count, t.hidden, t.locked, t.applicable , coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.vote END), 0) as rating - , CASE WHEN count(lie) filter(where lie) > 0 and count(lie) filter (where lie) >= count(lie)>>1 THEN -1 - ELSE coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.spoiler END), t.defaultspoil) END as spoiler + , coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.spoiler END), t.defaultspoil) as spoiler + , count(lie) filter(where not tv.ignore and lie) > 0 and count(lie) filter (where not tv.ignore and lie) >= count(lie) filter (where not tv.ignore)>>1 as islie , bool_or(tv.ignore) as overruled FROM tags t JOIN tags_vn tv ON tv.tag = t.id @@ -93,7 +93,7 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub { GROUP BY t.id, t.name, t.cat ORDER BY t.name' ); - enrich_merge id => sub { sql 'SELECT tag AS id, vote, CASE WHEN lie THEN', \3, 'ELSE spoiler END AS spoil, ignore, notes FROM tags_vn WHERE', { uid => auth->uid, vid => $v->{id} } }, $tags; + enrich_merge id => sub { sql 'SELECT tag AS id, vote, spoiler AS spoil, lie, ignore, notes FROM tags_vn WHERE', { uid => auth->uid, vid => $v->{id} } }, $tags; enrich othnotes => id => tag => sub { sql('SELECT tv.tag, ', sql_user(), ', tv.notes FROM tags_vn tv JOIN users u ON u.id = tv.uid WHERE tv.notes <> \'\' AND uid IS DISTINCT FROM (', \auth->uid, ') AND vid=', \$v->{id}) }, $tags; @@ -101,6 +101,7 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub { for(@$tags) { $_->{vote} //= 0; $_->{spoil} //= undef; + $_->{lie} //= undef; $_->{notes} //= ''; $_->{overrule} = $_->{vote} && !$_->{ignore} && $_->{overruled}; $_->{othnotes} = join "\n", map user_displayname($_).': '.$_->{notes}, $_->{othnotes}->@*; |