From a46e13727038e2d3dabeb8b1ce6a6903fb5c6edd Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Tue, 8 Aug 2023 12:02:25 +0200 Subject: [PATCH 1/5] back to dev --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c2c0004..a8208fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.5 +0.3.6.dev0 From 29908bfac80a5cf9dc6878fa5ee60e173c3c6d6d Mon Sep 17 00:00:00 2001 From: Fred C <42280769+hypsug0@users.noreply.github.com> Date: Wed, 30 Aug 2023 10:46:13 +0200 Subject: [PATCH 2/5] fix #40 --- src/utils_flask_sqla/generic.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/utils_flask_sqla/generic.py b/src/utils_flask_sqla/generic.py index d98a1b3..b29985a 100644 --- a/src/utils_flask_sqla/generic.py +++ b/src/utils_flask_sqla/generic.py @@ -237,10 +237,14 @@ def build_query_order(self, query, parameters): return query.order_by(ordel_col) return query - def raw_query(self, process_filter=True): + def set_limit(self, q): + return q.limit(self.limit).offset(self.offset * self.limit) + + def raw_query(self, process_filter=True, with_limit=True): """ Renvoie la requete 'brute' (sans .all) - process_filter: application des filtres (et du sort) + - with_limit: application de la limite sur la query """ q = self.DB.session.query(self.view.tableDef) @@ -251,8 +255,8 @@ def raw_query(self, process_filter=True): unordered_q = self.build_query_filters(q, self.filters) q = self.build_query_order(unordered_q, self.filters) - if self.limit != -1: - q = q.limit(self.limit).offset(self.offset * self.limit) + if self.limit != -1 and with_limit: + q = self.set_limit(q) return q @@ -260,15 +264,15 @@ def query(self): """ Lance la requete et retourne l'objet sqlalchemy """ - q = self.raw_query(process_filter=False) + q = self.DB.session.query(self.view.tableDef) nb_result_without_filter = q.count() - q = self.raw_query() - nb_results = q.count() if self.filters else nb_result_without_filter + q = self.raw_query(process_filter=True, with_limit=False) + total_filtered = q.count() if self.filters else nb_result_without_filter - data = q.all() + data = self.set_limit(q).all() - return data, nb_result_without_filter, nb_results + return data, nb_result_without_filter, total_filtered def return_query(self): """ From ded5d5815457f692d426352078dca7bebb322efa Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Wed, 13 Sep 2023 12:39:16 +0200 Subject: [PATCH 3/5] Add jwt headers in JsonClient if exist --- src/utils_flask_sqla/tests/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils_flask_sqla/tests/utils.py b/src/utils_flask_sqla/tests/utils.py index 749c007..e61e74e 100644 --- a/src/utils_flask_sqla/tests/utils.py +++ b/src/utils_flask_sqla/tests/utils.py @@ -24,5 +24,11 @@ def open(self, *args, **kwargs): } ) ) + # the set_logged_user_jwt add a jwt attribute to client with the current logged user + jwt = getattr(self, "jwt", None) + if jwt: + jwt_headers = Headers({"Authorization": f"Bearer {jwt}"}) + headers.extend(jwt_headers) + kwargs["headers"] = headers return super().open(*args, **kwargs) From b008c7539265311485d4c90ecf3de63fe4372a20 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Thu, 14 Sep 2023 10:14:04 +0200 Subject: [PATCH 4/5] prepa release --- VERSION | 2 +- docs/changelog.rst | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a8208fa..449d7e7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.6.dev0 +0.3.6 diff --git a/docs/changelog.rst b/docs/changelog.rst index 61b6517..3eeea81 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,13 @@ CHANGELOG ========= +0.3.6 (2023-09-14) +------------------ + +**🐛 Corrections** + +* Correction du `total_filtered` #40 by @lpofrec + 0.3.5 (2023-08-08) ------------------ From 9c47817cd064816cf645ccf61fee97ed58b8fbe7 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Thu, 14 Sep 2023 10:16:32 +0200 Subject: [PATCH 5/5] Revert "Add jwt headers in JsonClient if exist" This reverts commit a0790470b07aa51cfa8564bf7f3188497878adaf. --- src/utils_flask_sqla/tests/utils.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/utils_flask_sqla/tests/utils.py b/src/utils_flask_sqla/tests/utils.py index e61e74e..749c007 100644 --- a/src/utils_flask_sqla/tests/utils.py +++ b/src/utils_flask_sqla/tests/utils.py @@ -24,11 +24,5 @@ def open(self, *args, **kwargs): } ) ) - # the set_logged_user_jwt add a jwt attribute to client with the current logged user - jwt = getattr(self, "jwt", None) - if jwt: - jwt_headers = Headers({"Authorization": f"Bearer {jwt}"}) - headers.extend(jwt_headers) - kwargs["headers"] = headers return super().open(*args, **kwargs)