refactor(chalice): delete global session notes (#2064)

This commit is contained in:
Kraiem Taha Yassine 2024-04-09 13:52:05 +02:00 committed by GitHub
parent db72a079e4
commit d58a356f1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 10 deletions

View file

@ -125,16 +125,15 @@ def edit(tenant_id, user_id, project_id, note_id, data: schemas.SessionUpdateNot
return {"errors": ["Note not found"]}
def delete(tenant_id, user_id, project_id, note_id):
def delete(project_id, note_id):
with pg_client.PostgresClient() as cur:
cur.execute(
cur.mogrify(""" UPDATE public.sessions_notes
SET deleted_at = timezone('utc'::text, now())
WHERE note_id = %(note_id)s
AND project_id = %(project_id)s
AND user_id = %(user_id)s
AND deleted_at ISNULL;""",
{"project_id": project_id, "user_id": user_id, "note_id": note_id})
{"project_id": project_id, "note_id": note_id})
)
return {"data": {"state": "success"}}

View file

@ -485,8 +485,7 @@ def edit_note(projectId: int, noteId: int, data: schemas.SessionUpdateNoteSchema
@app.delete('/{projectId}/notes/{noteId}', tags=["sessions", "notes"])
def delete_note(projectId: int, noteId: int, _=Body(None), context: schemas.CurrentContext = Depends(OR_context)):
data = sessions_notes.delete(tenant_id=context.tenant_id, project_id=projectId, user_id=context.user_id,
note_id=noteId)
data = sessions_notes.delete(project_id=projectId, note_id=noteId)
return data

View file

@ -128,16 +128,15 @@ def edit(tenant_id, user_id, project_id, note_id, data: schemas.SessionUpdateNot
return row
def delete(tenant_id, user_id, project_id, note_id):
def delete(project_id, note_id):
with pg_client.PostgresClient() as cur:
cur.execute(
cur.mogrify(""" UPDATE public.sessions_notes
SET deleted_at = timezone('utc'::text, now())
WHERE note_id = %(note_id)s
AND project_id = %(project_id)s
AND user_id = %(user_id)s
AND deleted_at ISNULL;""",
{"project_id": project_id, "user_id": user_id, "note_id": note_id})
{"project_id": project_id, "note_id": note_id})
)
return {"data": {"state": "success"}}

View file

@ -521,8 +521,7 @@ def edit_note(projectId: int, noteId: int, data: schemas.SessionUpdateNoteSchema
@app.delete('/{projectId}/notes/{noteId}', tags=["sessions", "notes"],
dependencies=[OR_scope(Permissions.session_replay)])
def delete_note(projectId: int, noteId: int, _=Body(None), context: schemas.CurrentContext = Depends(OR_context)):
data = sessions_notes.delete(tenant_id=context.tenant_id, project_id=projectId, user_id=context.user_id,
note_id=noteId)
data = sessions_notes.delete(project_id=projectId, note_id=noteId)
return data