diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-05-15 15:53:34 +0000 |
---|---|---|
committer | Hakim Cassimally <hakim@mysociety.org> | 2014-10-16 16:56:26 +0000 |
commit | 06a69fa7a7e9fae205df36ddc68d131d91533792 (patch) | |
tree | 202a8451cc6539ff8f15652d0e15f53dedfa614c /t/open311/endpoint/Endpoint2.pm | |
parent | d1fee928f02dbc30d3a38b746155ce5b12be4a1b (diff) |
Open311 Endpoint mySociety extensions role
* Get Service Request Updates
This requires a new object ::Service::Request::Update, which of course
is not part of standard spec. So, in order to make the core not too
contaminated by :
* the endpoint should instantiate ::Service::Request::mySociety objects
which know about updates
* have added a learn_additional_types callback from Schema to Endpoint,
so that core doesn't need to know about /open311/service_request_update
* (but ::Spark knows about the exception for updates... meh, but is 1-line)
Diffstat (limited to 't/open311/endpoint/Endpoint2.pm')
-rw-r--r-- | t/open311/endpoint/Endpoint2.pm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/open311/endpoint/Endpoint2.pm b/t/open311/endpoint/Endpoint2.pm new file mode 100644 index 000000000..2b55b1e10 --- /dev/null +++ b/t/open311/endpoint/Endpoint2.pm @@ -0,0 +1,29 @@ +package t::open311::endpoint::Endpoint2; +use Web::Simple; +extends 't::open311::endpoint::Endpoint1'; +with 'Open311::Endpoint::Role::mySociety'; + +use Open311::Endpoint::Service::Request::mySociety; + +use constant request_class => 'Open311::Endpoint::Service::Request::mySociety'; + +sub get_service_request_updates { + my ($self, $args) = @_; + + my $start_date = $self->maybe_inflate_datetime($args->{start_date}); + my $end_date = $self->maybe_inflate_datetime($args->{end_date}); + + my @requests = $self->filter_requests( sub { $_[0]->has_updates } ); + + return map { + $_->filter_updates( sub { + my $update = shift; + my $updated_datetime = $update->updated_datetime or return; + if ($start_date) { return unless $updated_datetime >= $start_date } + if ($end_date) { return unless $updated_datetime <= $end_date } + return 1; + }); + } @requests; +} + +1; |