From 85852bf2f0391d197c06f6e8cb40674c0a81bd5e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 10 Sep 2023 11:07:37 +0200 Subject: [PATCH 1/3] Added check with -xp to get_level --- kdb-bot/src/modules/level/service/level_service.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 3dccade3..c7de2b75 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -40,6 +40,9 @@ class LevelService: def get_level(self, user: User) -> Level: levels_by_server = self._levels.get_levels_by_server_id(user.server.id) + if user.xp < 0: + levels_by_server.first() + levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) if levels.count() == 0: -- 2.45.2 From 731f80bd5fc82fcf14e2bd43c58a651f5487be26 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 10 Sep 2023 11:14:11 +0200 Subject: [PATCH 2/3] Fixed negative xp check --- kdb-bot/src/modules/level/service/level_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index c7de2b75..485df472 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -41,7 +41,7 @@ class LevelService: def get_level(self, user: User) -> Level: levels_by_server = self._levels.get_levels_by_server_id(user.server.id) if user.xp < 0: - levels_by_server.first() + levels_by_server.order_by(lambda l: l.min_xp).first() levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) -- 2.45.2 From ed9b893c12f0cb6ead54e8cbcf661ed3881df5f8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 10 Sep 2023 18:21:30 +0200 Subject: [PATCH 3/3] Fixed negative xp check --- kdb-bot/src/modules/level/service/level_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdb-bot/src/modules/level/service/level_service.py b/kdb-bot/src/modules/level/service/level_service.py index 485df472..e85c1719 100644 --- a/kdb-bot/src/modules/level/service/level_service.py +++ b/kdb-bot/src/modules/level/service/level_service.py @@ -41,7 +41,7 @@ class LevelService: def get_level(self, user: User) -> Level: levels_by_server = self._levels.get_levels_by_server_id(user.server.id) if user.xp < 0: - levels_by_server.order_by(lambda l: l.min_xp).first() + return levels_by_server.order_by(lambda l: l.min_xp).first() levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp) -- 2.45.2