Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/backend.py
Show First 20 Lines • Show All 768 Lines • ▼ Show 20 Lines | ) -> None: | ||||
visit_type, | visit_type, | ||||
last_eventful, | last_eventful, | ||||
last_uneventful, | last_uneventful, | ||||
last_failed, | last_failed, | ||||
last_snapshot | last_snapshot | ||||
) | ) | ||||
VALUES (%s, %s, %s, %s, %s, %s) ON CONFLICT (url, visit_type) DO | VALUES (%s, %s, %s, %s, %s, %s) ON CONFLICT (url, visit_type) DO | ||||
UPDATE | UPDATE | ||||
SET last_eventful = coalesce( | SET last_eventful = ( | ||||
excluded.last_eventful, | select max(eventful.date) from (values | ||||
ovi.last_eventful | (excluded.last_eventful), | ||||
(ovi.last_eventful) | |||||
) as eventful(date) | |||||
), | ), | ||||
last_uneventful = coalesce( | last_uneventful = ( | ||||
excluded.last_uneventful, | select max(uneventful.date) from (values | ||||
ovi.last_uneventful | (excluded.last_uneventful), | ||||
(ovi.last_uneventful) | |||||
) as uneventful(date) | |||||
), | ), | ||||
last_failed = coalesce( | last_failed = ( | ||||
excluded.last_failed, | select max(failed.date) from (values | ||||
ovi.last_failed | (excluded.last_failed), | ||||
(ovi.last_failed) | |||||
) as failed(date) | |||||
), | ), | ||||
last_snapshot = coalesce( | last_snapshot = (select | ||||
excluded.last_snapshot, | case | ||||
ovi.last_snapshot | when ovi.last_eventful < excluded.last_eventful then excluded.last_snapshot | ||||
when ovi.last_eventful <= excluded.last_eventful then ovi.last_snapshot | |||||
else ovi.last_snapshot -- touch nothing | |||||
ardumont: i explicitely kept the when cases for now but that can be shortened. | |||||
end | |||||
) | ) | ||||
""" | """ # noqa | ||||
cur.execute( | cur.execute( | ||||
query, | query, | ||||
( | ( | ||||
visit_stats.url, | visit_stats.url, | ||||
visit_stats.visit_type, | visit_stats.visit_type, | ||||
visit_stats.last_eventful, | visit_stats.last_eventful, | ||||
visit_stats.last_uneventful, | visit_stats.last_uneventful, | ||||
Show All 20 Lines |
i explicitely kept the when cases for now but that can be shortened.