feat(chalice): changes
This commit is contained in:
parent
0d26b1cc9a
commit
c3913e6dca
4 changed files with 16 additions and 14 deletions
|
|
@ -40,7 +40,7 @@ def __group_metadata(session, project_metadata):
|
|||
return meta
|
||||
|
||||
|
||||
def get_by_id2_pg(tenant_id, project_id, session_id, user_id, full_data=False, include_fav_viewed=False,
|
||||
def get_by_id2_pg(project_id, session_id, context: schemas.CurrentContext, full_data=False, include_fav_viewed=False,
|
||||
group_metadata=False, live=True):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
extra_query = []
|
||||
|
|
@ -64,7 +64,7 @@ def get_by_id2_pg(tenant_id, project_id, session_id, user_id, full_data=False, i
|
|||
FROM public.sessions AS s {"INNER JOIN public.projects AS p USING (project_id)" if group_metadata else ""}
|
||||
WHERE s.project_id = %(project_id)s
|
||||
AND s.session_id = %(session_id)s;""",
|
||||
{"project_id": project_id, "session_id": session_id, "userId": user_id}
|
||||
{"project_id": project_id, "session_id": session_id, "userId": context.user_id}
|
||||
)
|
||||
# print("===============")
|
||||
# print(query)
|
||||
|
|
@ -100,12 +100,11 @@ def get_by_id2_pg(tenant_id, project_id, session_id, user_id, full_data=False, i
|
|||
data['resources'] = resources.get_by_session_id(session_id=session_id, project_id=project_id,
|
||||
start_ts=data["startTs"], duration=data["duration"])
|
||||
|
||||
data['notes'] = sessions_notes.get_session_notes(tenant_id=tenant_id, project_id=project_id,
|
||||
session_id=session_id, user_id=user_id)
|
||||
data['notes'] = sessions_notes.get_session_notes(tenant_id=context.tenant_id, project_id=project_id,
|
||||
session_id=session_id, user_id=context.user_id)
|
||||
data['metadata'] = __group_metadata(project_metadata=data.pop("projectMetadata"), session=data)
|
||||
data['issues'] = issues.get_by_session_id(session_id=session_id, project_id=project_id)
|
||||
data['live'] = live and assist.is_live(project_id=project_id,
|
||||
session_id=session_id,
|
||||
data['live'] = live and assist.is_live(project_id=project_id, session_id=session_id,
|
||||
project_key=data["projectKey"])
|
||||
data["inDB"] = True
|
||||
return data
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ def create(tenant_id, user_id, project_id, session_id, data: schemas.SessionNote
|
|||
RETURNING *;""",
|
||||
{"user_id": user_id, "project_id": project_id, "session_id": session_id, **data.dict()})
|
||||
cur.execute(query)
|
||||
result = cur.fetchone()
|
||||
return helper.dict_to_camel_case(result)
|
||||
result = helper.dict_to_camel_case(cur.fetchone())
|
||||
if result:
|
||||
result["createdAt"] = TimeUTC.datetime_to_timestamp(result["createdAt"])
|
||||
return result
|
||||
|
||||
|
||||
def edit(tenant_id, user_id, project_id, note_id, data: schemas.SessionUpdateNoteSchema):
|
||||
|
|
@ -94,8 +96,7 @@ def delete(tenant_id, user_id, project_id, note_id):
|
|||
cur.execute(
|
||||
cur.mogrify("""\
|
||||
UPDATE public.sessions_notes
|
||||
SET
|
||||
deleted_at = timezone('utc'::text, now())
|
||||
SET deleted_at = timezone('utc'::text, now())
|
||||
WHERE
|
||||
note_id = %(note_id)s
|
||||
AND project_id = %(project_id)s\
|
||||
|
|
|
|||
|
|
@ -175,8 +175,8 @@ def get_session(projectId: int, sessionId: Union[int, str], background_tasks: Ba
|
|||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
if isinstance(sessionId, str):
|
||||
return {"errors": ["session not found"]}
|
||||
data = sessions.get_by_id2_pg(tenant_id=context.tenant_id, project_id=projectId, session_id=sessionId,
|
||||
full_data=True, user_id=context.user_id, include_fav_viewed=True, group_metadata=True)
|
||||
data = sessions.get_by_id2_pg(project_id=projectId, session_id=sessionId, full_data=True,
|
||||
include_fav_viewed=True, group_metadata=True, context=context)
|
||||
if data is None:
|
||||
return {"errors": ["session not found"]}
|
||||
if data.get("inDB"):
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ def create(tenant_id, user_id, project_id, session_id, data: schemas.SessionNote
|
|||
RETURNING *;""",
|
||||
{"user_id": user_id, "project_id": project_id, "session_id": session_id, **data.dict()})
|
||||
cur.execute(query)
|
||||
result = cur.fetchone()
|
||||
return helper.dict_to_camel_case(result)
|
||||
result = helper.dict_to_camel_case(cur.fetchone())
|
||||
if result:
|
||||
result["createdAt"] = TimeUTC.datetime_to_timestamp(result["createdAt"])
|
||||
return result
|
||||
|
||||
|
||||
def edit(tenant_id, user_id, project_id, note_id, data: schemas.SessionUpdateNoteSchema):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue