Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pcgv2 timestamp json #469

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pychunkedgraph/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions pychunkedgraph/app/segmentation/v1/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,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 -------------------------------------------------------------------
Expand Down Expand Up @@ -398,7 +398,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/<table_id>/root/<root_id>/change_log", methods=["GET"])
Expand All @@ -422,7 +422,7 @@ def tabular_change_log(table_id, root_id):
tab_change_log = tab_change_log_dict[int(root_id)]
if disp:
return tab_change_log.to_html()
return tab_change_log.to_json()
return jsonify_with_kwargs(tab_change_log)


@bp.route("/table/<table_id>/tabular_change_log_many", methods=["GET"])
Expand Down
Loading