File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,25 @@ def urls():
4949 cur = conn .cursor ()
5050 cur .execute ('SELECT * FROM urls ORDER BY created_at DESC' )
5151 urls = cur .fetchall ()
52- cur .execute ('SELECT created_at FROM url_checks ORDER BY created_at DESC' )
53- checks = cur .fetchall ()
52+
53+ cur .execute ('''
54+ SELECT u.id, u.name, u.created_at,
55+ uc.status_code, uc.created_at AS last_check
56+ FROM urls u
57+ LEFT JOIN url_checks uc ON u.id = uc.url_id
58+ WHERE uc.created_at = (
59+ SELECT MAX(created_at)
60+ FROM url_checks
61+ WHERE url_id = u.id
62+ )
63+ ORDER BY u.created_at DESC
64+ ''' )
65+ urls = cur .fetchall ()
66+
5467 cur .close ()
5568 conn .close ()
5669
57- return render_template ('urls.html' , urls = urls , checks = checks )
70+ return render_template ('urls.html' , urls = urls )
5871
5972
6073@app .route ('/urls/<int:url_id>' , methods = ['GET' ])
You can’t perform that action at this time.
0 commit comments