(swh) ✔ ~/swh/swh-environment/swh-storage [master ↓·1|✚ 1⚑ 17] 14:06 $ git diff -U13 diff --git a/swh/storage/sql/40-funcs.sql b/swh/storage/sql/40-funcs.sql index 626f0b3d..ce3a298d 100644 --- a/swh/storage/sql/40-funcs.sql +++ b/swh/storage/sql/40-funcs.sql @@ -816,34 +816,34 @@ $$; -- Find the visit of origin closest to date visit_date -- Breaks ties by selecting the largest visit id create or replace function swh_visit_find_by_date(origin_url text, visit_date timestamptz default NOW()) returns setof origin_visit language plpgsql stable as $$ declare origin_id bigint; begin select id into origin_id from origin where url=origin_url; return query with closest_two_visits as (( - select ov, (date - visit_date), visit as interval + select ov, (date - visit_date) as interval, visit from origin_visit ov where ov.origin = origin_id and ov.date >= visit_date order by ov.date asc, ov.visit desc limit 1 ) union ( - select ov, (visit_date - date), visit as interval + select ov, (visit_date - date) as interval, visit from origin_visit ov where ov.origin = origin_id and ov.date < visit_date order by ov.date desc, ov.visit desc limit 1 )) select (ov).* from closest_two_visits order by interval, visit limit 1; end $$; -- Object listing by object_id create or replace function swh_content_list_by_object_id( min_excl bigint,