Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAS-1400 use native sql #450

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -839,23 +839,11 @@ paths:
format: uuid
pricem14pc marked this conversation as resolved.
Show resolved Hide resolved
responses:
200:
description: list of dict enrolments
description: dict of respondent enrolments and associated business and survey details
content:
application/json:
schema:
type: array
items:
type: object
properties:
business_id:
type: string
format: uuid
status:
type: string
example: ENABLED
survey_id:
type: string
format: uuid
$ref: '#/components/schemas/RespondentEnrolments'
400:
description: Missing of malformed parameters
404:
Expand Down Expand Up @@ -1726,4 +1714,32 @@ components:
time_shared:
type: string
format: date-time
example: 2020-01-01T00:00:00Z
example: 2020-01-01T00:00:00Z
RespondentEnrolments:
type: object
properties:
enrolment_status:
type: string
enum: [PENDING, ENABLED, DISABLED, SUSPENDED]
business_details:
type: object
properties:
id:
format: uuid
name:
type: string
trading_as:
type: string
ref:
type: string
survey_details:
type: object
properties:
id:
format: uuid
long_name:
type: string
short_name:
type: string
ref:
type: string
2 changes: 1 addition & 1 deletion ras_party/controllers/enrolments_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def respondent_enrolments(
"ref": enrolment.business_ref,
},
"survey_details": {
"id": enrolment.survey_id,
"id": survey_id,
"long_name": surveys_details.get(survey_id)["long_name"],
"short_name": surveys_details.get(survey_id)["short_name"],
"ref": surveys_details.get(survey_id)["ref"],
Expand Down
4 changes: 2 additions & 2 deletions ras_party/controllers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ def query_respondent_enrolments(

return session.execute(
text(
f"SELECT * FROM partysvc.enrolment "
f"SELECT business_id, status, survey_id, business_ref, attributes from partysvc.enrolment "
f"inner join partysvc.business on partysvc.business.party_uuid = partysvc.enrolment.business_id, "
f"LATERAL (SELECT * FROM partysvc.business_attributes "
f"LATERAL (SELECT attributes FROM partysvc.business_attributes "
pricem14pc marked this conversation as resolved.
Show resolved Hide resolved
f"WHERE partysvc.enrolment.business_id = partysvc.business_attributes.business_id "
f"ORDER BY partysvc.business_attributes.created_on DESC limit 1) ba {where_clause}"
)
Expand Down
Loading