From 88b7656e2006ca08b6fc7e0800f18115d776419d Mon Sep 17 00:00:00 2001 From: Yro Boros Date: Tue, 3 Mar 2026 20:15:58 +1000 Subject: [PATCH] =?UTF-8?q?ip=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.py b/main.py index 7e6c9b7..fed947d 100644 --- a/main.py +++ b/main.py @@ -211,6 +211,32 @@ def get_records(): if conn: conn.close() +@app.get("/records_all_status", summary="Получить все записи избранного", response_model=List[ParsedData]) +def get_records(): + """ + Возвращает записи из таблицы url с избранным. + """ + conn = None + try: + conn = get_connection() + with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur: + cur.execute(""" + SELECT url, parsed_at, title, original_text, article_date, status, viewed, other, category, translation_text, short_text + FROM url + WHERE status = true + ORDER BY parsed_at DESC + """) + rows = cur.fetchall() + results = [dict(row) for row in rows] + urls = [item['parsed_at'] for item in results] + + print(urls) + return results + except Exception as e: + raise HTTPException(status_code=500, detail=f"Ошибка при получении записей из БД: {e}") + finally: + if conn: + conn.close() # get_records()