summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-10-15 17:10:48 +0200
committerYorhel <git@yorhel.nl>2020-10-15 17:10:50 +0200
commit739ab13ed3d0941237d9b29d1d62bd7d2ae31ac7 (patch)
treebe2bb03efd8bb2c16b1936ca339c675a0d6c3246
parent6bfab2213c1a033a02d9f390a89412a98695b664 (diff)
imgflag: Experiment with making average calculation more conservative
If an imgmod voted a more conservative option than the average, then the imgmod's vote will be used as average. This is to catch cases where most voters didn't notice a subtle suggestive or explicit part of the image. I mean, if a mod votes more conservative, they must be on to something.
-rw-r--r--sql/func.sql6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/func.sql b/sql/func.sql
index 0d86dcd9..7728873a 100644
--- a/sql/func.sql
+++ b/sql/func.sql
@@ -170,8 +170,10 @@ BEGIN
ELSE 0 END AS weight
FROM (
SELECT i.id, count(iv.id) AS votecount
- , avg(sexual) FILTER(WHERE NOT iv.ignore) AS sexual_avg, stddev_pop(sexual) FILTER(WHERE NOT iv.ignore) AS sexual_stddev
- , avg(violence) FILTER(WHERE NOT iv.ignore) AS violence_avg, stddev_pop(violence) FILTER(WHERE NOT iv.ignore) AS violence_stddev
+ , greatest(avg(sexual) FILTER(WHERE NOT iv.ignore), max(sexual) FILTER(WHERE u.perm_imgmod)) AS sexual_avg
+ , greatest(avg(violence) FILTER(WHERE NOT iv.ignore), max(violence) FILTER(WHERE u.perm_imgmod)) AS violence_avg
+ , stddev_pop(sexual) FILTER(WHERE NOT iv.ignore) AS sexual_stddev
+ , stddev_pop(violence) FILTER(WHERE NOT iv.ignore) AS violence_stddev
FROM images i
LEFT JOIN image_votes iv ON iv.id = i.id
LEFT JOIN users u ON u.id = iv.uid