From 3345aabdc7680609ad7c5bd1e49cf06139a217d7 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Thu, 12 May 2022 08:16:37 +0000 Subject: [PATCH] fixed bug --- skgyorugo/commands/available.py | 47 +++++++++++++++++++++++----- skgyorugo/commands/forceavailable.py | 47 +++++++++++++++++++++++----- 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/skgyorugo/commands/available.py b/skgyorugo/commands/available.py index 30efb22..5daf971 100644 --- a/skgyorugo/commands/available.py +++ b/skgyorugo/commands/available.py @@ -143,14 +143,16 @@ def main(bot: Bot, message: Message): ELSE 0 END ), - position = 1 + ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( SELECT max(position) FROM @@ -168,6 +170,34 @@ def main(bot: Bot, message: Message): name = 'queuesize' ) ) + THEN 1 + ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + ELSE position + END ), time_remaining = time_remaining - (? - last_available) WHERE @@ -175,6 +205,7 @@ def main(bot: Bot, message: Message): AND available = 0; """, ( + twitch_id, twitch_id, int(time.time()), twitch_id, diff --git a/skgyorugo/commands/forceavailable.py b/skgyorugo/commands/forceavailable.py index 09d68d9..4a0a06c 100644 --- a/skgyorugo/commands/forceavailable.py +++ b/skgyorugo/commands/forceavailable.py @@ -146,14 +146,16 @@ def main(bot: Bot, message: Message): ELSE 0 END ), - position = 1 + ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( SELECT max(position) FROM @@ -171,6 +173,34 @@ def main(bot: Bot, message: Message): name = 'queuesize' ) ) + THEN 1 + ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + ELSE position + END ), time_remaining = time_remaining - (? - last_available) WHERE @@ -178,6 +208,7 @@ def main(bot: Bot, message: Message): AND available = 0; """, ( + twitch_id, twitch_id, int(time.time()), twitch_id, -- 2.30.2