Skip to content

Commit 6e1a609

Browse files
committed
step 4 done.
1 parent cb03300 commit 6e1a609

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

page_analyzer/app.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ def index():
4747
def urls():
4848
conn = get_db_connection()
4949
cur = conn.cursor()
50+
51+
# Объединяем запросы для получения всех URL и последней проверки
5052
cur.execute('''
51-
SELECT u.id, u.name, u.created_at,
52-
uc.status_code, uc.created_at AS last_check
53-
FROM urls u
54-
LEFT JOIN url_checks uc ON u.id = uc.url_id
55-
AND uc.created_at = (
56-
SELECT MAX(created_at)
57-
FROM url_checks
58-
WHERE url_id = u.id
59-
)
60-
ORDER BY u.created_at DESC
61-
''')
53+
SELECT u.id, u.name, u.created_at,
54+
uc.status_code, uc.created_at AS last_check
55+
FROM urls u
56+
LEFT JOIN url_checks uc ON u.id = uc.url_id
57+
AND uc.created_at = (
58+
SELECT MAX(created_at)
59+
FROM url_checks
60+
WHERE url_id = u.id
61+
)
62+
ORDER BY u.created_at DESC
63+
''')
64+
urls = cur.fetchall()
65+
6266
cur.close()
6367
conn.close()
6468

0 commit comments

Comments
 (0)