Skip to content

Commit

Permalink
when query json data, uuid must convert to str
Browse files Browse the repository at this point in the history
  • Loading branch information
pphetra committed Jun 17, 2024
1 parent f666f37 commit 654e51e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions reports/schema/mutations/submit_image_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,21 @@ def mutate(root, info, report_id, image, is_cover, image_id):
image_url=image.file.url,
)

image_id_str = str(image_id)
# lookup image_id in form_data of subject record
record = SubjectRecord.objects.filter(
Q(form_data__house_front__has_key=image_id)
| Q(form_data__consent_image__has_key=image_id)
Q(form_data__house_front__has_key=image_id_str)
| Q(form_data__consent_image__has_key=image_id_str)
).first()
print("find image in subject record", record)

if not record:
record = MonitoringRecord.objects.filter(
Q(form_data__deploy_image__has_key=image_id)
| Q(form_data__indoor_container_neg__has_key=image_id)
| Q(form_data__outdoor_container_neg__has_key=image_id)
| Q(form_data__outdoor_container_pos__has_key=image_id)
| Q(form_data__indoor_container_neg__value__has_key=image_id)
Q(form_data__deploy_image__has_key=image_id_str)
| Q(form_data__indoor_container_neg__has_key=image_id_str)
| Q(form_data__outdoor_container_neg__has_key=image_id_str)
| Q(form_data__outdoor_container_pos__has_key=image_id_str)
| Q(form_data__indoor_container_neg__value__has_key=image_id_str)
).first()
print("find image in monitoring record", record)

Expand Down

0 comments on commit 654e51e

Please sign in to comment.