From b4d8e45e5df474f9837ed9585b0497a2a4224fe1 Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Fri, 3 Nov 2023 22:04:37 +0100 Subject: [PATCH] Api v1.15.0 (#1610) * refactor(chalice): refactored users code * fix(chalice): fixed path analysis empty exclude support * fix(chalice): fixed update notes --- api/chalicelib/core/sessions_notes.py | 6 ++++-- api/schemas/schemas.py | 12 +++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/api/chalicelib/core/sessions_notes.py b/api/chalicelib/core/sessions_notes.py index c51c8eeb5..89e5c6d3d 100644 --- a/api/chalicelib/core/sessions_notes.py +++ b/api/chalicelib/core/sessions_notes.py @@ -86,7 +86,8 @@ def create(tenant_id, user_id, project_id, session_id, data: schemas.SessionNote query = cur.mogrify(f"""INSERT INTO public.sessions_notes (message, user_id, tag, session_id, project_id, timestamp, is_public) VALUES (%(message)s, %(user_id)s, %(tag)s, %(session_id)s, %(project_id)s, %(timestamp)s, %(is_public)s) RETURNING *,(SELECT name FROM users WHERE users.user_id=%(user_id)s) AS user_name;""", - {"user_id": user_id, "project_id": project_id, "session_id": session_id, **data.model_dump()}) + {"user_id": user_id, "project_id": project_id, "session_id": session_id, + **data.model_dump()}) cur.execute(query) result = helper.dict_to_camel_case(cur.fetchone()) if result: @@ -120,7 +121,8 @@ def edit(tenant_id, user_id, project_id, note_id, data: schemas.SessionUpdateNot row = helper.dict_to_camel_case(cur.fetchone()) if row: row["createdAt"] = TimeUTC.datetime_to_timestamp(row["createdAt"]) - return row + return row + return {"errors": ["Note not found"]} def delete(tenant_id, user_id, project_id, note_id): diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index fbe628069..edd1b9f98 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -1464,13 +1464,7 @@ class SessionUpdateNoteSchema(SessionNoteSchema): @model_validator(mode='after') def __validator(cls, values): - assert len(values.keys()) > 0, "at least 1 attribute should be provided for update" - c = 0 - for v in values.values(): - if v is not None and (not isinstance(v, str) or len(v) > 0): - c += 1 - break - assert c > 0, "at least 1 value should be provided for update" + assert values.message is not None or values.timestamp is not None or values.is_public is not None, "at least 1 attribute should be provided for update" return values @@ -1578,6 +1572,6 @@ class FeatureFlagSchema(BaseModel): class ModuleStatus(BaseModel): module: Literal["assist", "notes", "bug-reports", - "offline-recordings", "alerts", "assist-statts", "recommendations", "feature-flags"] = Field(..., description="Possible values: assist, notes, bug-reports, offline-recordings, alerts, assist-statts, recommendations, feature-flags") + "offline-recordings", "alerts", "assist-statts", "recommendations", "feature-flags"] = Field(..., + description="Possible values: assist, notes, bug-reports, offline-recordings, alerts, assist-statts, recommendations, feature-flags") status: bool = Field(...) -