Skip to content
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

Prevent Open311 updates from being sent out of order #5298

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions perllib/Open311/PostServiceRequestUpdates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@
return;
}

# Comments are ordered randomly.
# Some cobrands/APIs do not handle ordering by age their end (e.g.
# Northumberland + Alloy) so we skip comment for now if an older unsent
# one exists for the problem. Otherwise an older update may overwrite a
# newer one in Alloy etc.
my @unsent_comments_for_problem
= $problem->comments->search(
{ state => 'confirmed', send_state => 'unprocessed' }
)->order_by('confirmed');

for ( @unsent_comments_for_problem ) {
if ( $_->id != $comment->id && $_->confirmed < $comment->confirmed ) {
$self->log( $comment,

Check warning on line 197 in perllib/Open311/PostServiceRequestUpdates.pm

View check run for this annotation

Codecov / codecov/patch

perllib/Open311/PostServiceRequestUpdates.pm#L197

Added line #L197 was not covered by tests
'Skipping for now because of older unprocessed update' );
return;

Check warning on line 199 in perllib/Open311/PostServiceRequestUpdates.pm

View check run for this annotation

Codecov / codecov/patch

perllib/Open311/PostServiceRequestUpdates.pm#L199

Added line #L199 was not covered by tests
}
}

# Some cobrands (e.g. Buckinghamshire) don't want to receive updates
# from anyone except the original problem reporter.
if (my $skip = $cobrand->call_hook(should_skip_sending_update => $comment)) {
Expand Down