Skip to content

Commit a8c92b0

Browse files
committed
step 4 done.
1 parent 1c0c101 commit a8c92b0

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

page_analyzer/app.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,14 @@ def index():
4747
def urls():
4848
conn = get_db_connection()
4949
cur = conn.cursor()
50-
# Получение всех URL и последней проверки для каждого URL
5150
cur.execute('SELECT * FROM urls ORDER BY created_at DESC')
52-
cur.execute('''
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-
WHERE 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-
''')
6451
urls = cur.fetchall()
65-
52+
cur.execute('SELECT created_at FROM url_checks ORDER BY created_at DESC')
53+
checks = cur.fetchall()
6654
cur.close()
6755
conn.close()
6856

69-
return render_template('urls.html', urls=urls)
57+
return render_template('urls.html', urls=urls, checks=checks)
7058

7159

7260
@app.route('/urls/<int:url_id>', methods=['GET'])

0 commit comments

Comments
 (0)