feat(api): dashboard format created_at and edited_at

This commit is contained in:
Taha Yassine Kraiem 2022-04-06 17:51:07 +02:00
parent 7e3597521c
commit 54ef9a248b
2 changed files with 11 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import schemas
from chalicelib.core import custom_metrics, dashboard
from chalicelib.utils import helper
from chalicelib.utils import pg_client
from chalicelib.utils.TimeUTC import TimeUTC
CATEGORY_DESCRIPTION = {
'categ1': 'lorem',
@ -21,6 +22,9 @@ def get_templates(project_id, user_id):
rows = cur.fetchall()
for r in rows:
r["description"] = CATEGORY_DESCRIPTION.get(r["category"], "")
for w in r["widgets"]:
w["created_at"] = TimeUTC.datetime_to_timestamp(w["created_at"])
w["edited_at"] = TimeUTC.datetime_to_timestamp(w["edited_at"])
return helper.list_to_camel_case(rows)
@ -85,6 +89,10 @@ def get_dashboard(project_id, user_id, dashboard_id):
params = {"userId": user_id, "projectId": project_id, "dashboard_id": dashboard_id}
cur.execute(cur.mogrify(pg_query, params))
row = cur.fetchone()
if row is not None:
for w in row["widgets"]:
row["created_at"] = TimeUTC.datetime_to_timestamp(w["created_at"])
row["edited_at"] = TimeUTC.datetime_to_timestamp(w["edited_at"])
return helper.dict_to_camel_case(row)

View file

@ -394,7 +394,7 @@ def delete_sumologic(projectId: int, context: schemas.CurrentContext = Depends(O
def get_integration_status(context: schemas.CurrentContext = Depends(OR_context)):
error, integration = integrations_manager.get_integration(tenant_id=context.tenant_id,
user_id=context.user_id)
if error is not None:
if error is not None and integration is None:
return {"data": {}}
return {"data": integration.get_obfuscated()}
@ -406,7 +406,7 @@ def add_edit_jira_cloud(data: schemas.JiraGithubSchema = Body(...),
error, integration = integrations_manager.get_integration(tool=integration_jira_cloud.PROVIDER,
tenant_id=context.tenant_id,
user_id=context.user_id)
if error is not None:
if error is not None and integration is None:
return error
data.provider = integration_jira_cloud.PROVIDER
return {"data": integration.add_edit(data=data.dict())}
@ -429,7 +429,7 @@ def add_edit_github(data: schemas.JiraGithubSchema = Body(...),
def delete_default_issue_tracking_tool(context: schemas.CurrentContext = Depends(OR_context)):
error, integration = integrations_manager.get_integration(tenant_id=context.tenant_id,
user_id=context.user_id)
if error is not None:
if error is not None and integration is None:
return error
return {"data": integration.delete()}