Skip to content
Snippets Groups Projects
Verified Commit 0a370722 authored by Georg Krause's avatar Georg Krause
Browse files

Make sure all known domains are updated

parent fbd5ed8c
No related branches found
No related tags found
No related merge requests found
Pipeline #26537 passed with stages
in 7 minutes and 33 seconds
......@@ -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)
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment