Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #42 from Aymen-Mohammednur/17.0-develop-aymen
Browse files Browse the repository at this point in the history
Fix issue with sorting 17.0-develop
  • Loading branch information
shibu-narayanan committed Sep 2, 2024
2 parents cfd95f3 + 549669e commit 9c8a183
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions g2p_odk_importer/models/odk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ def import_delta_records(self, last_sync_timestamp=None, skip=0, top=100):
_logger.exception("Failed to parse response: %s", e)
raise ValidationError(f"Failed to parse response: {e}") from e

# Sort the list of submissions based on the submission_time field
# Sort the list of submissions based on the submission_time field if it exists
data["value"] = sorted(
data["value"],
key=lambda x: parser.parse(x["submission_time"])
if x.get("submission_time") not in (None, "")
else None,
key=lambda x: (
x.get("submission_time") in (None, ""), # True for invalid times, sorts to end
parser.parse(x["submission_time"]) if x.get("submission_time") not in (None, "") else None,
),
)

for member in data["value"]:
Expand Down

0 comments on commit 9c8a183

Please sign in to comment.