feat(chalice): changed get record
feat(chalice): paginate through records
This commit is contained in:
parent
54f5bb6ede
commit
c2acfda9fb
2 changed files with 5 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ def search_records(project_id, data: schemas_ee.AssistRecordSearchPayloadSchema,
|
|||
"assist_records.created_at<=%(endDate)s"]
|
||||
params = {"tenant_id": context.tenant_id, "project_id": project_id,
|
||||
"startDate": data.startDate, "endDate": data.endDate,
|
||||
"p_start": (data.page - 1) * data.limit, "p_end": data.page * data.limit,
|
||||
"p_start": (data.page - 1) * data.limit, "p_limit": data.limit,
|
||||
**data.dict()}
|
||||
if data.user_id is not None:
|
||||
conditions.append("assist_records.user_id=%(user_id)s")
|
||||
|
|
@ -43,7 +43,9 @@ def search_records(project_id, data: schemas_ee.AssistRecordSearchPayloadSchema,
|
|||
FROM assist_records
|
||||
INNER JOIN projects USING (project_id)
|
||||
LEFT JOIN users USING (user_id)
|
||||
WHERE {" AND ".join(conditions)};""",
|
||||
WHERE {" AND ".join(conditions)}
|
||||
ORDER BY assist_records.created_at
|
||||
LIMIT %(p_limit)s OFFSET %(p_start)s;""",
|
||||
params)
|
||||
cur.execute(query)
|
||||
results = helper.list_to_camel_case(cur.fetchall())
|
||||
|
|
|
|||
|
|
@ -90,5 +90,5 @@ def search_records(projectId: int, data: schemas_ee.AssistRecordSearchPayloadSch
|
|||
|
||||
|
||||
@app.get('/{projectId}/assist/records/{recordId}', tags=["assist"])
|
||||
def search_records(projectId: int, recordId: int, context: schemas_ee.CurrentContext = Depends(OR_context)):
|
||||
def get_record(projectId: int, recordId: int, context: schemas_ee.CurrentContext = Depends(OR_context)):
|
||||
return {"data": assist_records.get_record(project_id=projectId, record_id=recordId, context=context)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue