Skip to content

Commit

Permalink
馃懛 Resolve inconsistent repeat_records order.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaapstorm committed Jan 22, 2021
1 parent 406ff20 commit b302830
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions corehq/motech/repeaters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ def repeater(self):

@property
def repeat_records_ready(self):
return self.repeat_records.filter(state__in=(RECORD_PENDING_STATE,
RECORD_FAILURE_STATE))
return (self.repeat_records
.order_by('registered_at')
.filter(state__in=(RECORD_PENDING_STATE,
RECORD_FAILURE_STATE)))

@property
def is_ready(self):
Expand Down
2 changes: 1 addition & 1 deletion corehq/motech/repeaters/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_send_request_fails(self):
process_repeater_stub(self.repeater_stub)

# Only the first record was attempted, the rest are still pending
states = [r.state for r in self.repeater_stub.repeat_records.all()]
states = [r.state for r in self.repeater_stub.repeat_records_ready]
self.assertListEqual(states, ([RECORD_FAILURE_STATE]
+ [RECORD_PENDING_STATE] * 9))

Expand Down

0 comments on commit b302830

Please sign in to comment.