Skip to content

Commit

Permalink
Quick Fix: APCD, List registrations for submitter is broken (#398)
Browse files Browse the repository at this point in the history
* Fix syntax error in sql

* move left join before where
  • Loading branch information
chandra-tacc authored Dec 9, 2024
1 parent 9c17c06 commit 733d781
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apcd_cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ def get_registrations(reg_id=None, submitter_code=None):
registrations.state,
registrations.zip,
registrations.registration_year
FROM registrations
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
{f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = ANY(%s) ORDER BY registrations.registration_id" if submitter_code is not None else ''}
ORDER BY registrations.registration_id desc"""

FROM registrations
{f"LEFT JOIN registration_submitters ON registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id" if submitter_code is not None else ''}
WHERE 1=1
{f" AND registrations.registration_id = {str(reg_id)}" if reg_id is not None else ''}
{f" AND submitters.submitter_code = ANY(%s)" if submitter_code is not None else ''}
ORDER BY registrations.registration_id"""
cur = conn.cursor()
if submitter_code:
cur.execute(query, (submitter_code,))
Expand Down

0 comments on commit 733d781

Please sign in to comment.