aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm9
-rw-r--r--t/open311/getservicerequestupdates.t13
-rw-r--r--templates/web/base/report/new/category.html1
3 files changed, 15 insertions, 8 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 11bc1e64f..daa5fb64d 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -89,6 +89,13 @@ sub update_comments {
# what problem it belongs to so just skip
next unless $request_id;
+ my $comment_time = eval {
+ DateTime::Format::W3CDTF->parse_datetime( $request->{updated_datetime} || "" );
+ };
+ next if $@;
+ my $updated = DateTime::Format::W3CDTF->format_datetime($comment_time->clone->set_time_zone('UTC'));
+ next if @args && ($updated lt $args[0] || $updated gt $args[1]);
+
my $problem;
my $criteria = {
external_id => $request_id,
@@ -99,8 +106,6 @@ sub update_comments {
my $c = $p->comments->search( { external_id => $request->{update_id} } );
if ( !$c->first ) {
- my $comment_time = DateTime::Format::W3CDTF->parse_datetime( $request->{updated_datetime} );
-
my $comment = $self->schema->resultset('Comment')->new(
{
problem => $p,
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index a57d2d0e6..134d5422e 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -38,7 +38,7 @@ UPDATED_DATETIME
};
-my $dt = DateTime->now;
+my $dt = DateTime->now(formatter => DateTime::Format::W3CDTF->new);
# basic xml -> perl object tests
for my $test (
@@ -571,7 +571,8 @@ subtest 'check that existing comments are not duplicated' => sub {
is $problem->comments->count, 1, 'one comment before fetching updates';
$requests_xml =~ s/UPDATED_DATETIME2/$dt/;
- $requests_xml =~ s/UPDATED_DATETIME/@{[ $comment->confirmed ]}/;
+ my $confirmed = DateTime::Format::W3CDTF->format_datetime($comment->confirmed);
+ $requests_xml =~ s/UPDATED_DATETIME/$confirmed/;
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $requests_xml } );
@@ -596,12 +597,12 @@ subtest 'check that existing comments are not duplicated' => sub {
foreach my $test ( {
desc => 'check that closed and then open comment results in correct state',
- dt1 => $dt->subtract( hours => 1 ),
+ dt1 => $dt->clone->subtract( hours => 1 ),
dt2 => $dt,
},
{
desc => 'check that old comments do not change problem status',
- dt1 => $dt->subtract( hours => 2 ),
+ dt1 => $dt->clone->subtract( minutes => 90 ),
dt2 => $dt,
}
) {
@@ -627,7 +628,7 @@ foreach my $test ( {
$problem->comments->delete;
$problem->state( 'confirmed' );
- $problem->lastupdate( $dt->subtract( hours => 3 ) );
+ $problem->lastupdate( $dt->clone->subtract( hours => 3 ) );
$problem->update;
$requests_xml =~ s/UPDATED_DATETIME/$test->{dt1}/;
@@ -683,7 +684,7 @@ foreach my $test ( {
$problem->comments->delete;
$problem->state( 'confirmed' );
- $problem->lastupdate( $dt->subtract( hours => 3 ) );
+ $problem->lastupdate( $dt->clone->subtract( hours => 3 ) );
$problem->update;
my @alerts = map {
diff --git a/templates/web/base/report/new/category.html b/templates/web/base/report/new/category.html
index a89a4d5e9..8cfbecdcd 100644
--- a/templates/web/base/report/new/category.html
+++ b/templates/web/base/report/new/category.html
@@ -5,6 +5,7 @@
END; %]
<label for='form_category' id="form_category_label">
[%- loc('Category') %]
+ </label>
<select name='category' id='form_category'>
[% FOREACH cat_op IN category_options %]
[% cat_op_lc = cat_op | lower %]