From 8c8ff4c79861ce060eb2c3bd1be2820f3e7b4790 Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Mon, 25 Sep 2023 12:59:52 -0700 Subject: [PATCH 1/2] v1 of datetime fix --- pychunkedgraph/app/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pychunkedgraph/app/__init__.py b/pychunkedgraph/app/__init__.py index 07c47c6db..89c002e9b 100644 --- a/pychunkedgraph/app/__init__.py +++ b/pychunkedgraph/app/__init__.py @@ -41,6 +41,9 @@ def default(self, obj): elif isinstance(obj, datetime.datetime): return obj.__str__() elif isinstance(obj, pd.DataFrame): + for col, col_dtype in obj.dtypes.items(): + if isinstance(col_dtype, pd.DatetimeTZDtype): + obj[col] = obj[col].map(lambda x: x.timestamp()) return obj.to_json() return json.JSONEncoder.default(self, obj) From 633a6031f7ef7c39a036a8a89cc20eb02990f71f Mon Sep 17 00:00:00 2001 From: Forrest Collman Date: Wed, 27 Sep 2023 15:55:27 -0700 Subject: [PATCH 2/2] adding jsonify with kwargs --- pychunkedgraph/app/segmentation/v1/routes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pychunkedgraph/app/segmentation/v1/routes.py b/pychunkedgraph/app/segmentation/v1/routes.py index a2816fb56..52a8e6c4d 100644 --- a/pychunkedgraph/app/segmentation/v1/routes.py +++ b/pychunkedgraph/app/segmentation/v1/routes.py @@ -177,7 +177,7 @@ def handle_user_operations(table_id): if disp: return user_operations.to_html() else: - return user_operations.to_json() + return jsonify_with_kwargs(user_operations) ### GET ROOT ------------------------------------------------------------------- @@ -380,7 +380,7 @@ def tabular_change_log_weekly(table_id): if disp: return weekly_tab_change_log.to_html() else: - return weekly_tab_change_log.to_json() + return jsonify_with_kwargs(weekly_tab_change_log) @bp.route("/table//root//change_log", methods=["GET"]) @@ -405,7 +405,8 @@ def tabular_change_log(table_id, root_id): if disp: return tab_change_log.to_html() else: - return tab_change_log.to_json() + return jsonify_with_kwargs(tab_change_log) + @bp.route("/table//tabular_change_log_many", methods=["GET"])