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

Update AssessmentValue global API #955

Merged
merged 14 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions hawc/apps/assessment/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def get_annotation_map(self, query_prefix: str) -> dict:
),
}

def prepare_df(self, df):
return self.format_time(df)


class AssessmentExport(ModelExport):
def get_value_map(self) -> dict:
Expand All @@ -53,6 +56,9 @@ def get_value_map(self) -> dict:
"last_updated": "last_updated",
}

def prepare_df(self, df):
return self.format_time(df)


class AssessmentDetailExport(ModelExport):
def get_value_map(self) -> dict:
Expand All @@ -70,6 +76,9 @@ def get_value_map(self) -> dict:
"last_updated": "last_updated",
}

def prepare_df(self, df):
return self.format_time(df)

def get_annotation_map(self, query_prefix: str) -> dict:
return {
"project_status_display": sql_display(
Expand Down
2 changes: 1 addition & 1 deletion hawc/apps/common/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def format_time(self, df: pd.DataFrame) -> pd.DataFrame:
tz = timezone.get_default_timezone()
for key in [self.get_column_name("created"), self.get_column_name("last_updated")]:
if key in df.columns:
df.loc[:, key] = df[key].dt.tz_convert(tz).dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
df[key] = df[key].dt.tz_convert(tz).dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
dannypeterson marked this conversation as resolved.
Show resolved Hide resolved
return df

def get_df(self, qs: QuerySet) -> pd.DataFrame:
Expand Down
2 changes: 1 addition & 1 deletion tests/hawc/apps/hawc_admin/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def test_assessment_values(self):
resp = client.get(url)
assert resp.status_code == 200
df = pd.read_json(StringIO(resp.content.decode()))
assert df.shape == (3, 33)
assert df.shape == (3, 41)
Loading