about summary refs log tree commit diff
path: root/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2024-08-16T22·34+0200
committerProfpatsch <mail@profpatsch.de>2024-09-13T11·13+0000
commit5e8729188b07b8999e47da43dc1c8cb5dc484ae2 (patch)
treed7c8036d1bae5a19f3f4523b38445a2a2d4c6ac6 /users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
parent158ba0d607c3b9cae23d2407587afa1c3e679376 (diff)
feat(users/Profpatsch/whatcd-resolver): adjust seeding_weight r/8673
* Prefer MP3 versions to save on ratio
* Definitely never download 24bit flacs, they are not worth it at all

One needs to remove the `seeding_weight` column and restart
for it to have any effect (no real migrations yet, but eh)

bump

Change-Id: I30cc3ea05c4352316e3929f93d90fc27ce833682
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12222
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs')
-rw-r--r--users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs24
1 files changed, 22 insertions, 2 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
index ad363090ffdd..cfca79f04fbb 100644
--- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
+++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
@@ -730,7 +730,8 @@ migrate = inSpan "Database Migration" $ do
     CREATE OR REPLACE FUNCTION calc_seeding_weight(full_json_result jsonb) RETURNS int AS $$
     BEGIN
       RETURN
-        ((full_json_result->'seeders')::integer*3
+        -- three times seeders plus one times snatches
+        (3 * (full_json_result->'seeders')::integer
         + (full_json_result->'snatches')::integer
         )
         -- prefer remasters by multiplying them with 3
@@ -738,7 +739,26 @@ migrate = inSpan "Database Migration" $ do
             WHEN full_json_result->>'remasterTitle' ILIKE '%remaster%'
             THEN 3
             ELSE 1
-          END);
+          END)
+        -- slightly push mp3 V0, to make sure it’s preferred over 320 CBR
+        * (CASE
+            WHEN full_json_result->>'encoding' ILIKE '%v0%'
+            THEN 2
+            ELSE 1
+          END)
+        -- remove 24bit torrents from the result (wayyy too big)
+        * (CASE
+            WHEN full_json_result->>'encoding' ILIKE '%24bit%'
+            THEN 0
+            ELSE 1
+          END)
+        -- discount FLACS, so we only use them when there’s no mp3 alternative (to save space)
+        / (CASE
+            WHEN full_json_result->>'encoding' ILIKE '%lossless%'
+            THEN 5
+            ELSE 1
+          END)
+        ;
     END;
     $$ LANGUAGE plpgsql IMMUTABLE;