Api v1.15.0 (#1586)

* fix(chalice): fixed insights card
This commit is contained in:
Kraiem Taha Yassine 2023-10-27 16:41:23 +02:00 committed by GitHub
parent 799fa9b77a
commit a62bd95d9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 125 deletions

View file

@ -11,7 +11,6 @@ public_app, app, app_apikey = get_routers()
@app.post('/{projectId}/dashboards', tags=["dashboard"])
# @app.put('/{projectId}/dashboards', tags=["dashboard"])
def create_dashboards(projectId: int, data: schemas.CreateDashboardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return dashboards.create_dashboard(project_id=projectId, user_id=context.user_id, data=data)
@ -30,7 +29,6 @@ def get_dashboard(projectId: int, dashboardId: int, context: schemas.CurrentCont
return {"data": data}
# @app.post('/{projectId}/dashboards/{dashboardId}', tags=["dashboard"])
@app.put('/{projectId}/dashboards/{dashboardId}', tags=["dashboard"])
def update_dashboard(projectId: int, dashboardId: int, data: schemas.EditDashboardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -50,8 +48,6 @@ def pin_dashboard(projectId: int, dashboardId: int, context: schemas.CurrentCont
@app.post('/{projectId}/dashboards/{dashboardId}/cards', tags=["cards"])
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets', tags=["dashboard"])
# @app.put('/{projectId}/dashboards/{dashboardId}/widgets', tags=["dashboard"])
def add_card_to_dashboard(projectId: int, dashboardId: int,
data: schemas.AddWidgetToDashboardPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -68,7 +64,6 @@ def create_metric_and_add_to_dashboard(projectId: int, dashboardId: int,
dashboard_id=dashboardId, data=data)}
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}', tags=["dashboard"])
@app.put('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}', tags=["dashboard"])
def update_widget_in_dashboard(projectId: int, dashboardId: int, widgetId: int,
data: schemas.UpdateWidgetPayloadSchema = Body(...),
@ -84,30 +79,13 @@ def remove_widget_from_dashboard(projectId: int, dashboardId: int, widgetId: int
widget_id=widgetId)
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}/chart', tags=["dashboard"])
# def get_widget_chart(projectId: int, dashboardId: int, widgetId: int,
# data: schemas.CardChartSchema = Body(...),
# context: schemas.CurrentContext = Depends(OR_context)):
# data = dashboards.make_chart_widget(project_id=projectId, user_id=context.user_id, dashboard_id=dashboardId,
# widget_id=widgetId, data=data)
# if data is None:
# return {"errors": ["widget not found"]}
# return {"data": data}
@app.post('/{projectId}/cards/try', tags=["cards"])
# @app.post('/{projectId}/metrics/try', tags=["dashboard"])
# @app.put('/{projectId}/metrics/try', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/try', tags=["customMetrics"])
def try_card(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_chart(project_id=projectId, data=data, user_id=context.user_id)}
@app.post('/{projectId}/cards/try/sessions', tags=["cards"])
# @app.post('/{projectId}/metrics/try/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try/sessions', tags=["customMetrics"])
def try_card_sessions(projectId: int, data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.get_sessions(project_id=projectId, user_id=context.user_id, data=data)
@ -115,41 +93,29 @@ def try_card_sessions(projectId: int, data: schemas.CardSessionsSchema = Body(..
@app.post('/{projectId}/cards/try/issues', tags=["cards"])
# @app.post('/{projectId}/metrics/try/issues', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try/issues', tags=["customMetrics"])
def try_card_issues(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_issues(project_id=projectId, user_id=context.user_id, data=data)}
@app.get('/{projectId}/cards', tags=["cards"])
# @app.get('/{projectId}/metrics', tags=["dashboard"])
# @app.get('/{projectId}/custom_metrics', tags=["customMetrics"])
def get_cards(projectId: int, context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_all(project_id=projectId, user_id=context.user_id)}
@app.post('/{projectId}/cards', tags=["cards"])
# @app.post('/{projectId}/metrics', tags=["dashboard"])
# @app.put('/{projectId}/metrics', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics', tags=["customMetrics"])
def create_card(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return custom_metrics.create_card(project_id=projectId, user_id=context.user_id, data=data)
@app.post('/{projectId}/cards/search', tags=["cards"])
# @app.post('/{projectId}/metrics/search', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/search', tags=["customMetrics"])
def search_cards(projectId: int, data: schemas.SearchCardsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.search_all(project_id=projectId, user_id=context.user_id, data=data)}
@app.get('/{projectId}/cards/{metric_id}', tags=["cards"])
# @app.get('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.get('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def get_card(projectId: int, metric_id: Union[int, str], context: schemas.CurrentContext = Depends(OR_context)):
if metric_id.isnumeric():
metric_id = int(metric_id)
@ -161,17 +127,7 @@ def get_card(projectId: int, metric_id: Union[int, str], context: schemas.Curren
return {"data": data}
# @app.get('/{projectId}/cards/{metric_id}/thumbnail', tags=["cards"])
# def sign_thumbnail_for_upload(projectId: int, metric_id: Union[int, str],
# context: schemas.CurrentContext = Depends(OR_context)):
# if not isinstance(metric_id, int):
# return {"errors": ["invalid card_id"]}
# return custom_metrics.add_thumbnail(metric_id=metric_id, user_id=context.user_id, project_id=projectId)
@app.post('/{projectId}/cards/{metric_id}/sessions', tags=["cards"])
# @app.post('/{projectId}/metrics/{metric_id}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/sessions', tags=["customMetrics"])
def get_card_sessions(projectId: int, metric_id: int,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -183,8 +139,6 @@ def get_card_sessions(projectId: int, metric_id: int,
@app.post('/{projectId}/cards/{metric_id}/issues', tags=["cards"])
# @app.post('/{projectId}/metrics/{metric_id}/issues', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/issues', tags=["customMetrics"])
def get_card_funnel_issues(projectId: int, metric_id: Union[int, str],
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -201,8 +155,6 @@ def get_card_funnel_issues(projectId: int, metric_id: Union[int, str],
@app.post('/{projectId}/cards/{metric_id}/issues/{issueId}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/issues/{issueId}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/issues/{issueId}/sessions', tags=["customMetrics"])
def get_metric_funnel_issue_sessions(projectId: int, metric_id: int, issueId: str,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -214,8 +166,6 @@ def get_metric_funnel_issue_sessions(projectId: int, metric_id: int, issueId: st
@app.post('/{projectId}/cards/{metric_id}/errors', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/errors', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/errors', tags=["customMetrics"])
def get_card_errors_list(projectId: int, metric_id: int,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -227,8 +177,6 @@ def get_card_errors_list(projectId: int, metric_id: int,
@app.post('/{projectId}/cards/{metric_id}/chart', tags=["card"])
# @app.post('/{projectId}/metrics/{metric_id}/chart', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/chart', tags=["customMetrics"])
def get_card_chart(projectId: int, metric_id: int, request: Request, data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.make_chart_from_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id,
@ -237,10 +185,6 @@ def get_card_chart(projectId: int, metric_id: int, request: Request, data: schem
@app.post('/{projectId}/cards/{metric_id}', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.put('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def update_card(projectId: int, metric_id: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.update_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id, data=data)
@ -250,10 +194,6 @@ def update_card(projectId: int, metric_id: int, data: schemas.CardSchema = Body(
@app.post('/{projectId}/cards/{metric_id}/status', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/status', tags=["dashboard"])
# @app.put('/{projectId}/metrics/{metric_id}/status', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/status', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/{metric_id}/status', tags=["customMetrics"])
def update_card_state(projectId: int, metric_id: int,
data: schemas.UpdateCardStatusSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -263,8 +203,6 @@ def update_card_state(projectId: int, metric_id: int,
@app.delete('/{projectId}/cards/{metric_id}', tags=["dashboard"])
# @app.delete('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.delete('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def delete_card(projectId: int, metric_id: int, _=Body(None),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.delete_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id)}

View file

@ -1248,7 +1248,7 @@ class CardInsights(__CardSchema):
@model_validator(mode="after")
def __transform(cls, values):
values.metric_of = MetricOtherViewType(values.metric_of)
values.metric_of = MetricOfInsights(values.metric_of)
return values
@model_validator(mode='after')

View file

@ -11,7 +11,6 @@ public_app, app, app_apikey = get_routers([OR_scope(schemas.Permissions.metrics)
@app.post('/{projectId}/dashboards', tags=["dashboard"])
# @app.put('/{projectId}/dashboards', tags=["dashboard"])
def create_dashboards(projectId: int, data: schemas.CreateDashboardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return dashboards.create_dashboard(project_id=projectId, user_id=context.user_id, data=data)
@ -30,7 +29,6 @@ def get_dashboard(projectId: int, dashboardId: int, context: schemas.CurrentCont
return {"data": data}
# @app.post('/{projectId}/dashboards/{dashboardId}', tags=["dashboard"])
@app.put('/{projectId}/dashboards/{dashboardId}', tags=["dashboard"])
def update_dashboard(projectId: int, dashboardId: int, data: schemas.EditDashboardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -50,8 +48,6 @@ def pin_dashboard(projectId: int, dashboardId: int, context: schemas.CurrentCont
@app.post('/{projectId}/dashboards/{dashboardId}/cards', tags=["cards"])
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets', tags=["dashboard"])
# @app.put('/{projectId}/dashboards/{dashboardId}/widgets', tags=["dashboard"])
def add_card_to_dashboard(projectId: int, dashboardId: int,
data: schemas.AddWidgetToDashboardPayloadSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -68,7 +64,6 @@ def create_metric_and_add_to_dashboard(projectId: int, dashboardId: int,
dashboard_id=dashboardId, data=data)}
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}', tags=["dashboard"])
@app.put('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}', tags=["dashboard"])
def update_widget_in_dashboard(projectId: int, dashboardId: int, widgetId: int,
data: schemas.UpdateWidgetPayloadSchema = Body(...),
@ -84,30 +79,13 @@ def remove_widget_from_dashboard(projectId: int, dashboardId: int, widgetId: int
widget_id=widgetId)
# @app.post('/{projectId}/dashboards/{dashboardId}/widgets/{widgetId}/chart', tags=["dashboard"])
# def get_widget_chart(projectId: int, dashboardId: int, widgetId: int,
# data: schemas.CardChartSchema = Body(...),
# context: schemas.CurrentContext = Depends(OR_context)):
# data = dashboards.make_chart_widget(project_id=projectId, user_id=context.user_id, dashboard_id=dashboardId,
# widget_id=widgetId, data=data)
# if data is None:
# return {"errors": ["widget not found"]}
# return {"data": data}
@app.post('/{projectId}/cards/try', tags=["cards"])
# @app.post('/{projectId}/metrics/try', tags=["dashboard"])
# @app.put('/{projectId}/metrics/try', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/try', tags=["customMetrics"])
def try_card(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_chart(project_id=projectId, data=data, user_id=context.user_id)}
@app.post('/{projectId}/cards/try/sessions', tags=["cards"])
# @app.post('/{projectId}/metrics/try/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try/sessions', tags=["customMetrics"])
def try_card_sessions(projectId: int, data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.get_sessions(project_id=projectId, user_id=context.user_id, data=data)
@ -115,41 +93,29 @@ def try_card_sessions(projectId: int, data: schemas.CardSessionsSchema = Body(..
@app.post('/{projectId}/cards/try/issues', tags=["cards"])
# @app.post('/{projectId}/metrics/try/issues', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/try/issues', tags=["customMetrics"])
def try_card_issues(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_issues(project_id=projectId, user_id=context.user_id, data=data)}
@app.get('/{projectId}/cards', tags=["cards"])
# @app.get('/{projectId}/metrics', tags=["dashboard"])
# @app.get('/{projectId}/custom_metrics', tags=["customMetrics"])
def get_cards(projectId: int, context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.get_all(project_id=projectId, user_id=context.user_id)}
@app.post('/{projectId}/cards', tags=["cards"])
# @app.post('/{projectId}/metrics', tags=["dashboard"])
# @app.put('/{projectId}/metrics', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics', tags=["customMetrics"])
def create_card(projectId: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return custom_metrics.create_card(project_id=projectId, user_id=context.user_id, data=data)
@app.post('/{projectId}/cards/search', tags=["cards"])
# @app.post('/{projectId}/metrics/search', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/search', tags=["customMetrics"])
def search_cards(projectId: int, data: schemas.SearchCardsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.search_all(project_id=projectId, user_id=context.user_id, data=data)}
@app.get('/{projectId}/cards/{metric_id}', tags=["cards"])
# @app.get('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.get('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def get_card(projectId: int, metric_id: Union[int, str], context: schemas.CurrentContext = Depends(OR_context)):
if metric_id.isnumeric():
metric_id = int(metric_id)
@ -161,17 +127,7 @@ def get_card(projectId: int, metric_id: Union[int, str], context: schemas.Curren
return {"data": data}
# @app.get('/{projectId}/cards/{metric_id}/thumbnail', tags=["cards"])
# def sign_thumbnail_for_upload(projectId: int, metric_id: Union[int, str],
# context: schemas.CurrentContext = Depends(OR_context)):
# if not isinstance(metric_id, int):
# return {"errors": ["invalid card_id"]}
# return custom_metrics.add_thumbnail(metric_id=metric_id, user_id=context.user_id, project_id=projectId)
@app.post('/{projectId}/cards/{metric_id}/sessions', tags=["cards"])
# @app.post('/{projectId}/metrics/{metric_id}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/sessions', tags=["customMetrics"])
def get_card_sessions(projectId: int, metric_id: int,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -183,8 +139,6 @@ def get_card_sessions(projectId: int, metric_id: int,
@app.post('/{projectId}/cards/{metric_id}/issues', tags=["cards"])
# @app.post('/{projectId}/metrics/{metric_id}/issues', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/issues', tags=["customMetrics"])
def get_card_funnel_issues(projectId: int, metric_id: Union[int, str],
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -201,8 +155,6 @@ def get_card_funnel_issues(projectId: int, metric_id: Union[int, str],
@app.post('/{projectId}/cards/{metric_id}/issues/{issueId}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/issues/{issueId}/sessions', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/issues/{issueId}/sessions', tags=["customMetrics"])
def get_metric_funnel_issue_sessions(projectId: int, metric_id: int, issueId: str,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -214,8 +166,6 @@ def get_metric_funnel_issue_sessions(projectId: int, metric_id: int, issueId: st
@app.post('/{projectId}/cards/{metric_id}/errors', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/errors', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/errors', tags=["customMetrics"])
def get_card_errors_list(projectId: int, metric_id: int,
data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -227,8 +177,6 @@ def get_card_errors_list(projectId: int, metric_id: int,
@app.post('/{projectId}/cards/{metric_id}/chart', tags=["card"])
# @app.post('/{projectId}/metrics/{metric_id}/chart', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/chart', tags=["customMetrics"])
def get_card_chart(projectId: int, metric_id: int, request: Request, data: schemas.CardSessionsSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.make_chart_from_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id,
@ -237,10 +185,6 @@ def get_card_chart(projectId: int, metric_id: int, request: Request, data: schem
@app.post('/{projectId}/cards/{metric_id}', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.put('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def update_card(projectId: int, metric_id: int, data: schemas.CardSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
data = custom_metrics.update_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id, data=data)
@ -250,10 +194,6 @@ def update_card(projectId: int, metric_id: int, data: schemas.CardSchema = Body(
@app.post('/{projectId}/cards/{metric_id}/status', tags=["dashboard"])
# @app.post('/{projectId}/metrics/{metric_id}/status', tags=["dashboard"])
# @app.put('/{projectId}/metrics/{metric_id}/status', tags=["dashboard"])
# @app.post('/{projectId}/custom_metrics/{metric_id}/status', tags=["customMetrics"])
# @app.put('/{projectId}/custom_metrics/{metric_id}/status', tags=["customMetrics"])
def update_card_state(projectId: int, metric_id: int,
data: schemas.UpdateCardStatusSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
@ -263,8 +203,6 @@ def update_card_state(projectId: int, metric_id: int,
@app.delete('/{projectId}/cards/{metric_id}', tags=["dashboard"])
# @app.delete('/{projectId}/metrics/{metric_id}', tags=["dashboard"])
# @app.delete('/{projectId}/custom_metrics/{metric_id}', tags=["customMetrics"])
def delete_card(projectId: int, metric_id: int, _=Body(None),
context: schemas.CurrentContext = Depends(OR_context)):
return {"data": custom_metrics.delete_card(project_id=projectId, user_id=context.user_id, metric_id=metric_id)}