feat(chalice): add session_id to recordings

This commit is contained in:
Taha Yassine Kraiem 2022-11-15 16:38:20 +01:00
parent f9498939d9
commit 486ce2dc39
4 changed files with 10 additions and 3 deletions

View file

@ -16,11 +16,12 @@ def presign_records(project_id, data: schemas_ee.AssistRecordUploadPayloadSchema
key=s3.generate_file_key(project_id=project_id, key=key)))
params[f"name_{i}"] = r.name
params[f"duration_{i}"] = r.duration
params[f"session_id_{i}"] = r.session_id
params[f"key_{i}"] = key
with pg_client.PostgresClient() as cur:
values = [f"(%(project_id)s, %(user_id)s, %(name_{i})s, %(key_{i})s, %(duration_{i})s)" for i in
range(len(data.records))]
query = cur.mogrify(f"""INSERT INTO assist_records(project_id, user_id, name, file_key, duration)
values = [f"(%(project_id)s, %(user_id)s, %(name_{i})s, %(key_{i})s, %(duration_{i})s, %(session_id_{i})s)"
for i in range(len(data.records))]
query = cur.mogrify(f"""INSERT INTO assist_records(project_id, user_id, name, file_key, duration, session_id)
VALUES {",".join(values)}""", params)
cur.execute(query)
return results

View file

@ -86,6 +86,10 @@ class SessionModel(BaseModel):
class AssistRecord(BaseModel):
name: str = Field(...)
duration: int = Field(...)
session_id: int = Field(...)
class Config:
alias_generator = schemas.attribute_to_camel_case
class AssistRecordUploadPayloadSchema(BaseModel):

View file

@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS assist_records
record_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
session_id integer NOT NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
deleted_at timestamp without time zone NULL DEFAULT NULL,
name text NOT NULL,

View file

@ -1251,6 +1251,7 @@ $$
record_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
session_id integer NOT NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
deleted_at timestamp without time zone NULL DEFAULT NULL,
name text NOT NULL,