Skip to content

Commit

Permalink
Only update 'lastupdate' when the update is new.
Browse files Browse the repository at this point in the history
  • Loading branch information
neprune committed Feb 3, 2025
1 parent 21edb19 commit 61e7964
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion perllib/Open311/UpdatesBase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ sub _process_update {
# insertion. We also then need a clone, otherwise the setting of lastupdate
# will *also* reshift comment->created's time zone to TIME_ZONE.
my $created = $comment->created->set_time_zone(FixMyStreet->local_time_zone);
$p->lastupdate($created->clone);
if ($created > $p->lastupdate) {
$p->lastupdate($created->clone);
}

return $comment unless $self->commit;

Expand Down
2 changes: 2 additions & 0 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ subtest 'push updating of reports' => sub {
($report, $report2) = $mech->create_problems_for_body(2, $brent->id, 'Graffiti', {
category => 'Graffiti',
});
# Set last update to before the time of the first update we've mocked.
$report->update({ lastupdate => DateTime->new(year => 2020, month => 06, day => 23, hour => 15) });
my $report_id = $report->id;
my $cobrand = FixMyStreet::Cobrand::Brent->new;

Expand Down
2 changes: 2 additions & 0 deletions t/cobrand/bromley_waste.t
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ subtest 'updating of waste reports' => sub {
});
$reports[1]->update({ external_id => 'something-else' }); # To test loop
$report = $reports[0];
# Set last update to before the time of the first update we've mocked.
$report->update({ lastupdate => DateTime->new(year => 2020, month => 06, day => 23, hour => 15) });
my $cobrand = FixMyStreet::Cobrand::Bromley->new;

$report->update({ external_id => 'waste-15001-' });
Expand Down
4 changes: 3 additions & 1 deletion t/cobrand/sutton.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }

# Create test data
my $date = DateTime->now->subtract(days => 1)->strftime('%Y-%m-%dT%H:%M:%SZ');
my $user = $mech->create_user_ok( '[email protected]', name => 'Sutton Council' );
my $normal_user = $mech->create_user_ok( '[email protected]', name => 'Norma Normal' );
my $body = $mech->create_body_ok( 2498, 'Sutton Council', {
Expand Down Expand Up @@ -167,7 +168,6 @@ sub new { my $c = shift; bless { @_ }, $c; }
package main;

subtest 'updating of waste reports' => sub {
my $date = DateTime->now->subtract(days => 1)->strftime('%Y-%m-%dT%H:%M:%SZ');
my $integ = Test::MockModule->new('SOAP::Lite');
$integ->mock(call => sub {
my ($cls, @args) = @_;
Expand Down Expand Up @@ -216,6 +216,8 @@ subtest 'updating of waste reports' => sub {
});
$reports[1]->update({ external_id => 'something-else' }); # To test loop
$report = $reports[0];
# Set last update to before the time of the first update we've mocked.
$report->update({ lastupdate => $date });

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'sutton',
Expand Down

0 comments on commit 61e7964

Please sign in to comment.