File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,22 @@ def index():
4747def 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
You can’t perform that action at this time.
0 commit comments