From 9357a2ecfaefc81fd03774fe43bbce12d7b0bdda Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Sun, 21 Nov 2021 04:37:10 +0300 Subject: [PATCH] fix news hook --- hooks.py | 2 +- sql_requests.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hooks.py b/hooks.py index ce8ce43..eb7bbc6 100644 --- a/hooks.py +++ b/hooks.py @@ -267,7 +267,7 @@ def new_old_news_diff(column: str, db_conn: sqlite3.Connection, squad_id: int) - :param squad_id: :return: """ - sql_req: sqlite3.Cursor = db_conn.execute(sql_requests.select_old_new_news.format(column=column), (squad_id,)) + sql_req: sqlite3.Cursor = db_conn.execute(sql_requests.select_new_old_news.format(column=column), (squad_id,)) try: new = sql_req.fetchone()[0] diff --git a/sql_requests.py b/sql_requests.py index 143e878..288bc06 100644 --- a/sql_requests.py +++ b/sql_requests.py @@ -91,12 +91,17 @@ order by inserted_timestamp desc limit 2;""" # AAAAAAAAA, it require to do something with it -select_old_new_news: str = """select {column} -from squads_states inner join news on - squads_states.squad_id = news.squad_id - and substr(squads_states.inserted_timestamp, 1, 16) = substr(news.inserted_timestamp, 1, 16) -where category = 'Squadrons_History_Category_PublicStatement' and squads_states.squad_id = ? -order by squads_states.inserted_timestamp +# select_old_new_news: str = """select {column} +# from squads_states inner join news on +# squads_states.squad_id = news.squad_id +# and substr(squads_states.inserted_timestamp, 1, 16) = substr(news.inserted_timestamp, 1, 16) +# where category = 'Squadrons_History_Category_PublicStatement' and squads_states.squad_id = ? +# order by squads_states.inserted_timestamp +# limit 2;""" +select_new_old_news: str = """select {column} +from news +where squad_id = ? and category = 'Squadrons_History_Category_PublicStatement' +order by inserted_timestamp desc limit 2;""" select_important_before_delete: str = """select name, platform, member_count, tag, user_tags, created