From 0a3707226c87623d17f0480fb3861f87648f19f6 Mon Sep 17 00:00:00 2001 From: Georg Krause <mail@georg-krause.net> Date: Thu, 1 Dec 2022 18:32:54 +0100 Subject: [PATCH] Make sure all known domains are updated --- funkwhale_network/db.py | 8 ++++++++ funkwhale_network/worker.py | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/funkwhale_network/db.py b/funkwhale_network/db.py index d1f75ae..8360cf6 100644 --- a/funkwhale_network/db.py +++ b/funkwhale_network/db.py @@ -144,6 +144,14 @@ class DB: base_query = "SELECT DISTINCT on (domain) domain, * FROM checks INNER JOIN domains ON checks.domain = domains.name WHERE domains.blocked = false ORDER BY domain, time DESC" return base_query.format(where_clause=""), [] + async def get_all_domains(self): + with ( + await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + ) as cursor: + await cursor.execute("SELECT name FROM domains") + domains = list(await cursor.fetchall()) + return domains + async def get_domains(self, **kwargs): with ( await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) diff --git a/funkwhale_network/worker.py b/funkwhale_network/worker.py index c265a9b..4d93782 100644 --- a/funkwhale_network/worker.py +++ b/funkwhale_network/worker.py @@ -12,9 +12,12 @@ async def poll(ctx, domain): async def update_all(ctx): async with DB() as db: - domains = await db.get_latest_check_by_domain() + domains = await db.get_all_domains() + print(domains) for check in domains: - await poll(ctx, check["domain"]) + domain = check["name"] + print(f"Checking domain {domain}") + await poll(ctx, domain) async def startup(ctx): -- GitLab