]> Untitled Git - lemmy.git/blob - migrations/2023-07-06-151124_hot-rank-future/up.sql
detailed error message for blocked domains (#3698) (#3701)
[lemmy.git] / migrations / 2023-07-06-151124_hot-rank-future / up.sql
1 CREATE OR REPLACE FUNCTION hot_rank(score numeric, published timestamp without time zone)
2     RETURNS integer
3     AS $$
4 DECLARE
5     hours_diff numeric := EXTRACT(EPOCH FROM (timezone('utc', now()) - published)) / 3600;
6 BEGIN
7     IF (hours_diff > 0) THEN
8         RETURN floor(10000 * log(greatest(1, score + 3)) / power((hours_diff + 2), 1.8))::integer;
9     ELSE
10         RETURN 0;
11     END IF;
12 END;
13 $$
14 LANGUAGE plpgsql
15 IMMUTABLE PARALLEL SAFE;
16