From 242c49bc6c6aafdc263fa8ef2c8d325f361bf457 Mon Sep 17 00:00:00 2001 From: Travis Rivers <trivers@contractor.usgs.gov> Date: Tue, 17 Nov 2020 12:24:01 -0700 Subject: [PATCH] remove custom to_json method, use builtin json --- geomagio/api/db/metadata_table.py | 2 +- geomagio/api/secure/metadata.py | 3 +-- geomagio/metadata/Metadata.py | 4 ---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/geomagio/api/db/metadata_table.py b/geomagio/api/db/metadata_table.py index 05e5cfe43..f1286420e 100644 --- a/geomagio/api/db/metadata_table.py +++ b/geomagio/api/db/metadata_table.py @@ -131,7 +131,7 @@ async def get_metadata( if created_after: query = query.where(metadata.c.created_time > created_after) if created_before: - query = query = query.where(metadata.c.created_time < created_before) + query = query.where(metadata.c.created_time < created_before) if data_valid is not None: query = query.where(metadata.c.data_valid == data_valid) if metadata_valid is not None: diff --git a/geomagio/api/secure/metadata.py b/geomagio/api/secure/metadata.py index 3592e48b9..d69121045 100644 --- a/geomagio/api/secure/metadata.py +++ b/geomagio/api/secure/metadata.py @@ -36,8 +36,7 @@ async def create_metadata( user: User = Depends(require_user()), ): created_metadata = await metadata_table.create_metadata(metadata) - print(metadata.to_json()) - return Response(metadata.to_json(), status_code=201, media_type="application/json") + return Response(metadata.json(), status_code=201, media_type="application/json") @router.delete("/metadata/{id}") diff --git a/geomagio/metadata/Metadata.py b/geomagio/metadata/Metadata.py index eb8f5b8fd..ce2ad5211 100644 --- a/geomagio/metadata/Metadata.py +++ b/geomagio/metadata/Metadata.py @@ -1,5 +1,4 @@ from datetime import timezone -import json from typing import Dict from obspy import UTCDateTime @@ -88,6 +87,3 @@ class Metadata(BaseModel): @validator("created_time") def set_default_created_time(cls, created_time: UTCDateTime = None) -> UTCDateTime: return created_time or UTCDateTime() - - def to_json(self): - return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) -- GitLab