Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/backend.py
Show First 20 Lines • Show All 326 Lines • ▼ Show 20 Lines | ) -> List[ListedOrigin]: | ||||
""" | """ | ||||
origin_select_cols = ", ".join(ListedOrigin.select_columns()) | origin_select_cols = ", ".join(ListedOrigin.select_columns()) | ||||
# TODO: filter on last_scheduled "too recent" to avoid always | # TODO: filter on last_scheduled "too recent" to avoid always | ||||
# re-scheduling the same tasks. | # re-scheduling the same tasks. | ||||
where_clauses = ["enabled", "visit_type = %s"] | where_clauses = ["enabled", "visit_type = %s"] | ||||
if policy == "oldest_scheduled_first": | if policy == "oldest_scheduled_first": | ||||
order_by = "origin_visit_stats.last_scheduled NULLS FIRST" | order_by = "origin_visit_stats.last_scheduled NULLS FIRST" | ||||
elif policy == "never_visited_oldest_update_first": | |||||
# never visited origins have a NULL last_snapshot | |||||
where_clauses.append("origin_visit_stats.last_snapshot IS NULL") | |||||
# order by increasing last_update (oldest first) | |||||
where_clauses.append("listed_origins.last_update IS NOT NULL") | |||||
order_by = "listed_origins.last_update" | |||||
else: | else: | ||||
raise UnknownPolicy(f"Unknown scheduling policy {policy}") | raise UnknownPolicy(f"Unknown scheduling policy {policy}") | ||||
select_query = f""" | select_query = f""" | ||||
SELECT | SELECT | ||||
{origin_select_cols} | {origin_select_cols} | ||||
FROM | FROM | ||||
listed_origins | listed_origins | ||||
▲ Show 20 Lines • Show All 609 Lines • Show Last 20 Lines |