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

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

nephila-nacrea
Copy link
Contributor

@nephila-nacrea nephila-nacrea commented Dec 11, 2024

Updates are selected in random order but some cobrands/APIs (e.g. Northumberland/Alloy) do not know how to handle updates in order their end, so an earlier update may overwrite a later one.

This change checks that an update is not sent until earlier updates for that problem are sent.

Fixes https://github.com/mysociety/societyworks/issues/4640.

[skip changelog]

@nephila-nacrea nephila-nacrea self-assigned this Dec 11, 2024
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.42%. Comparing base (5ee915d) to head (97579a7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5298      +/-   ##
==========================================
+ Coverage   82.40%   82.42%   +0.02%     
==========================================
  Files         415      415              
  Lines       32855    32864       +9     
  Branches     5270     5271       +1     
==========================================
+ Hits        27074    27088      +14     
+ Misses       4223     4218       -5     
  Partials     1558     1558              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nephila-nacrea nephila-nacrea marked this pull request as ready for review December 12, 2024 20:25
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you can simplify the check for an earlier unprocessed comment :)

perllib/Open311/PostServiceRequestUpdates.pm Outdated Show resolved Hide resolved
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, so just one more small further step - you can get rid of the order_by (as you don't care any more), I'd add an id => { "!=" => $comment->id } to be on the safe side (not sure if there might be some rounding issues with the date formatting), add { rows => 1 } as a second parameter to search() (because you only care about getting one result) and then add ->single after the search, putting the result in a scalar, not an array (so you get that one result or undef). :)

Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks :)

@nephila-nacrea nephila-nacrea force-pushed the FD4750-prevent-out-of-order-updates branch from c10627f to 97579a7 Compare December 19, 2024 13:44
@nephila-nacrea nephila-nacrea merged commit 97579a7 into master Dec 19, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants