From 5e8729188b07b8999e47da43dc1c8cb5dc484ae2 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 17 Aug 2024 00:34:43 +0200 Subject: [PATCH] feat(users/Profpatsch/whatcd-resolver): adjust seeding_weight * 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 --- .../whatcd-resolver/src/WhatcdResolver.hs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs index ad363090f..cfca79f04 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;