-
Notifications
You must be signed in to change notification settings - Fork 132
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
Update GeoJSON endpoint to filter by instances with geoms #2335
Conversation
b764799
to
b321f11
Compare
4925713
to
6d62e10
Compare
Signed-off-by: Kipchirchir Sigei <[email protected]>
Signed-off-by: Kipchirchir Sigei <[email protected]>
Signed-off-by: Kipchirchir Sigei <[email protected]>
Signed-off-by: Kipchirchir Sigei <[email protected]>
6d62e10
to
9d36be5
Compare
).count() | ||
< 1 | ||
): | ||
self.object.xform.instances_with_geopoints = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have this implemented on the model level instead of the viewset ? Guessing this field is updated/set on the model level ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavisRayM Moved the logic to the instance model post save signal instead to handle the update after a submission is soft deleted. Note that with soft deletion the post_save signal is triggered instead of post_delete
Signed-off-by: Kipchirchir Sigei <[email protected]>
# update xform if no instance has geoms | ||
if ( | ||
instance.xform.instances.filter( | ||
deleted_at__isnull=True, geom=None | ||
).count() | ||
< 1 | ||
): | ||
instance.xform.instances_with_geopoints = False | ||
instance.xform.save() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have this happen in update_xform_submission_count
and let's try to avoid a count on the XForm. If possible let's use the Forms submission_count
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed via 4008f69
Signed-off-by: Kipchirchir Sigei <[email protected]>
2ae144d
to
4008f69
Compare
# update xform if no instance has geoms | ||
if ( | ||
instance.xform.instances.filter( | ||
deleted_at__isnull=True, geom=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query won't do what is expected; It's counts instances that are not deleted with no geoms... Let's use a query like xform.instances.filter(deleted_at__isnull=True).exclude(geom=None).count() < 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xform.instances.filter(~Q(geom=None), deleted_at__isnull=True).count() < 1
Signed-off-by: Kipchirchir Sigei <[email protected]>
Signed-off-by: Kipchirchir Sigei <[email protected]>
Changes / Features implemented
before
now
Steps taken to verify this change does what is intended
Side effects of implementing this change
Before submitting this PR for review, please make sure you have:
Closes #