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 <mail@profpatsch.de>
This commit is contained in:
parent
158ba0d607
commit
5e8729188b
1 changed files with 22 additions and 2 deletions
|
@ -730,7 +730,8 @@ migrate = inSpan "Database Migration" $ do
|
||||||
CREATE OR REPLACE FUNCTION calc_seeding_weight(full_json_result jsonb) RETURNS int AS $$
|
CREATE OR REPLACE FUNCTION calc_seeding_weight(full_json_result jsonb) RETURNS int AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN
|
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
|
+ (full_json_result->'snatches')::integer
|
||||||
)
|
)
|
||||||
-- prefer remasters by multiplying them with 3
|
-- prefer remasters by multiplying them with 3
|
||||||
|
@ -738,7 +739,26 @@ migrate = inSpan "Database Migration" $ do
|
||||||
WHEN full_json_result->>'remasterTitle' ILIKE '%remaster%'
|
WHEN full_json_result->>'remasterTitle' ILIKE '%remaster%'
|
||||||
THEN 3
|
THEN 3
|
||||||
ELSE 1
|
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;
|
END;
|
||||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue