@@ -11,8 +11,8 @@ async def get_crawler_status(request: web.Request) -> web.Response:
11
11
# Count resources with no check and resources with a check
12
12
q = f"""
13
13
SELECT
14
- SUM(CASE WHEN last_check IS NULL THEN 1 ELSE 0 END) AS count_never_checked,
15
- SUM(CASE WHEN last_check IS NOT NULL THEN 1 ELSE 0 END) AS count_checked
14
+ COALESCE( SUM(CASE WHEN last_check IS NULL THEN 1 ELSE 0 END), 0 ) AS count_never_checked,
15
+ COALESCE( SUM(CASE WHEN last_check IS NOT NULL THEN 1 ELSE 0 END), 0 ) AS count_checked
16
16
FROM catalog
17
17
WHERE { Resource .get_excluded_clause ()}
18
18
AND catalog.deleted = False
@@ -22,22 +22,19 @@ async def get_crawler_status(request: web.Request) -> web.Response:
22
22
now = datetime .now (timezone .utc )
23
23
q = f"""
24
24
SELECT
25
- SUM(CASE WHEN checks.next_check_at <= $1 THEN 1 ELSE 0 END) AS count_outdated
26
- --, SUM(CASE WHEN checks.next_check_at > $1 THEN 1 ELSE 0 END) AS count_fresh
25
+ COALESCE(SUM(CASE WHEN checks.next_check_at <= $1 THEN 1 ELSE 0 END), 0) AS count_outdated
27
26
FROM catalog, checks
28
27
WHERE { Resource .get_excluded_clause ()}
29
28
AND catalog.last_check = checks.id
30
29
AND catalog.deleted = False
31
30
"""
32
31
stats_checks : dict = await request .app ["pool" ].fetchrow (q , now )
33
32
34
- count_pending_checks : int = stats_resources [ "count_never_checked" ] + (
35
- stats_checks [ "count_outdated " ] or 0
33
+ count_pending_checks : int = (
34
+ stats_resources [ "count_never_checked " ] + stats_checks [ "count_outdated" ]
36
35
)
37
36
# all w/ a check, minus those with an outdated checked
38
- count_fresh_checks : int = stats_resources ["count_checked" ] - (
39
- stats_checks ["count_outdated" ] or 0
40
- )
37
+ count_fresh_checks : int = stats_resources ["count_checked" ] - stats_checks ["count_outdated" ]
41
38
total : int = stats_resources ["count_never_checked" ] + stats_resources ["count_checked" ]
42
39
rate_checked : float = round (stats_resources ["count_checked" ] / total * 100 , 1 )
43
40
rate_checked_fresh : float = round (count_fresh_checks / total * 100 , 1 )
0 commit comments