summaryrefslogtreecommitdiff
path: root/lib/Multi
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-04-09 10:30:26 +0200
committerYorhel <git@yorhel.nl>2021-04-09 10:30:28 +0200
commitc3e3e904b026900b4d2ce8086b0391248fc5249e (patch)
treeac55c209269e61fd60df39e2f2188a381f9735ba /lib/Multi
parent9e4318867ce948d1128fbaf30bd2dde3a399983e (diff)
Multi::Maintenance: delete tags assigned to Multi that have been voted on by others
https://vndb.org/t15139.10 A more elegant solution is probably to keep the votes but make them not count, as right now it means that votes won't be restored when the user who "overruled" Multi's vote ends up getting their votes ignored/deleted, but I don't expect that to be a common scenario.
Diffstat (limited to 'lib/Multi')
-rw-r--r--lib/Multi/Maintenance.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm
index f6e913af..382031e2 100644
--- a/lib/Multi/Maintenance.pm
+++ b/lib/Multi/Maintenance.pm
@@ -54,6 +54,15 @@ sub log_res {
my %dailies = (
+ # Delete tags assigned to Multi that also have (possibly inherited) votes from other users.
+ cleanmultitags => q|
+ WITH RECURSIVE
+ t_votes(tag,vid,uid) AS (SELECT tv.tag, tv.vid, tv.uid FROM tags_vn tv LEFT JOIN users u ON u.id = tv.uid WHERE tv.uid IS DISTINCT FROM 'u1' AND (u.id IS NULL OR u.perm_tag)),
+ t_inherit(tag,vid,uid) AS (SELECT * FROM t_votes UNION SELECT tp.parent, th.vid, th.uid FROM t_inherit th JOIN tags_parents tp ON tp.id = th.tag),
+ t_nonmulti(tag,vid) AS (SELECT DISTINCT tag, vid FROM t_inherit),
+ t_del(tag,vid) AS (SELECT tv.tag, tv.vid FROM tags_vn tv JOIN t_nonmulti tn ON (tn.tag,tn.vid) = (tv.tag,tv.vid) WHERE tv.uid = 'u1')
+ DELETE FROM tags_vn tv WHERE tv.uid = 'u1' AND EXISTS(SELECT 1 FROM t_del td WHERE (td.tag,td.vid) = (tv.tag,tv.vid))|,
+
# takes about 50ms to 500ms to complete, depending on how many releases have been released within the past 5 days
vncache_inc => q|
SELECT update_vncache(id)