diff options
author | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
commit | 09dacfc6b8bf62addeee16c20b1d90c2a256da96 (patch) | |
tree | 7caa2bf9e92227ab74448f9b746dd28bbcb81b2a /perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm | |
parent | 585e57484f9c6332668bf1ac0a6a3b39dbe32223 (diff) | |
parent | cea89fb87a96943708a1db0f646492fbfaaf000f (diff) |
Merge tag 'v3.1' into fiksgatami-devfiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm index 1805e1fd2..dd76a52c0 100644 --- a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm +++ b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm @@ -156,6 +156,20 @@ sub compare_photo { return FixMyStreet::Template::SafeString->new($s); } +# This is a list of extra keys that could be set on a report after a moderation +# has occurred. This can confuse the display of the last moderation entry, as +# the comparison with the problem's extra will be wrong. +my @keys_to_ignore = ( + 'sent_to', # SendReport::Email adds this arrayref when sent + 'closed_updates', # Marked to close a report to updates + 'closure_alert_sent_at', # Set by alert sending if update closes a report + # Can be set/changed by an Open311 update + 'external_status_code', 'customer_reference', + # Can be set by inspectors + 'traffic_information', 'detailed_information', 'duplicates', 'duplicate_of', 'order', +); +my %keys_to_ignore = map { $_ => 1 } @keys_to_ignore; + sub compare_extra { my ($self, $other) = @_; @@ -163,18 +177,20 @@ sub compare_extra { my $new = $other->get_extra_metadata; my $both = { %$old, %$new }; - my @all_keys = sort keys %$both; + my @all_keys = grep { !$keys_to_ignore{$_} } sort keys %$both; my @s; foreach (@all_keys) { + $old->{$_} = join(', ', @{$old->{$_}}) if ref $old->{$_} eq 'ARRAY'; + $new->{$_} = join(', ', @{$new->{$_}}) if ref $new->{$_} eq 'ARRAY'; if ($old->{$_} && $new->{$_}) { push @s, string_diff("$_ = $old->{$_}", "$_ = $new->{$_}"); } elsif ($new->{$_}) { push @s, string_diff("", "$_ = $new->{$_}"); - } else { + } elsif ($old->{$_}) { push @s, string_diff("$_ = $old->{$_}", ""); } } - return join ', ', grep { $_ } @s; + return join '; ', grep { $_ } @s; } sub extra_diff { @@ -193,7 +209,7 @@ sub string_diff { $new = FixMyStreet::Template::html_filter($new); if ($options{single}) { - return unless $old; + return '' unless $old; $old = [ $old ]; $new = [ $new ]; } |