Skip to content

Commit

Permalink
Merge branch 'brent-closed-age' into commercial-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 17, 2024
2 parents 4342066 + 17e5b9b commit e052655
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 31 deletions.
47 changes: 42 additions & 5 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,17 @@ sub oidc_config {
return $cfg;
}

=head2 Only show reports on map for last 3 months
Brent only show 3 months of report history on the map rather than default 6 months
=item * Show open reports for 3 months, closed/fixed for 1 month
=cut

sub report_age { '3 months' }
sub report_age {
return {
open => '3 months',
closed => '1 month',
fixed => '1 month',
};
}

=head2 dashboard_export_problems_add_columns
Expand Down Expand Up @@ -1151,6 +1155,15 @@ sub garden_container_data_extract {
}
}

sub waste_extra_service_info_all_results {
my ($self, $property, $result) = @_;

if (!(@$result && grep { $_->{ServiceId} == $self->garden_service_id } @$result)) {
# No garden collection possible
$self->{c}->stash->{waste_features}->{garden_disabled} = 1;
}
}

sub waste_extra_service_info {
my ($self, $property, @rows) = @_;

Expand Down Expand Up @@ -1646,7 +1659,8 @@ sub waste_munge_bulky_data {
$data->{extra_Batteries} = 1;
} elsif ($item eq 'Podback Bag') {
$data->{extra_Coffee_Pods} = 1;
} elsif ($item eq 'Paint, up to 5 litres capacity (1 x 5 litre tin, 5 x 1 litre tins etc.)') {
} elsif ($item eq 'Paint, up to 5 litres capacity (1 x 5 litre tin, 5 x 1 litre tins etc.)'
|| $item eq 'Paint, 1 can, up to 5 litres') {
$data->{extra_Paint} = 1;
} elsif ($item eq 'Textiles, up to 60 litres (one black sack / 3 carrier bags)') {
$data->{extra_Textiles} = 1;
Expand Down Expand Up @@ -1681,6 +1695,29 @@ sub waste_reconstruct_bulky_data {
return $saved_data;
}

=item bulky_open_overdue
Returns true if the booking is open the day after the day the collection was due.
=cut

sub bulky_open_overdue {
my ($self, $event) = @_;

if ($event->{state} eq 'open' && $self->_bulky_collection_overdue($event)) {
return 1;
}
}

sub _bulky_collection_overdue {
my $collection_due_date = $_[1]->{date};

$collection_due_date->add(days => 1)->truncate(to => 'day');
my $today = DateTime->now->set_time_zone($collection_due_date->time_zone);

return $today > $collection_due_date;
}

sub _barnet_non_street {
return [
'Abandoned vehicles',
Expand Down
22 changes: 18 additions & 4 deletions perllib/FixMyStreet/Cobrand/Surrey.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ sub disambiguate_location {
span => '0.4000678,0.9071629',
bounds => [ 51.0714965, -0.8489465, 51.4715643, 0.0582164 ],
town => 'Surrey',
string => $string,
};
}

Expand Down Expand Up @@ -59,6 +58,14 @@ sub send_questionnaires { 0 }

sub enter_postcode_text { 'Enter a nearby UK postcode, or street name and area' }


=item * Don't show reports before go live date
=cut

sub cut_off_date { '2024-09-16' }


=item * The privacy policy is held on Surrey's own site
=cut
Expand Down Expand Up @@ -103,6 +110,16 @@ sub get_town {
return $town;
}


=head2 get_geocoder
The OSM geocoder is used for Surrey.
=cut

sub get_geocoder { 'OSM' }


=head2 categories_restriction
Surrey don't want a particular district category on their cobrand.
Expand Down Expand Up @@ -157,9 +174,6 @@ sub open311_title_fetched_report {
return $request->{service_name};
}

sub get_geocoder { 'OSM'}


sub open311_config {
my ($self, $row, $h, $params, $contact) = @_;

Expand Down
13 changes: 12 additions & 1 deletion perllib/FixMyStreet/Cobrand/UKCouncils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,18 @@ sub problems_on_map_restriction {
my ($self, $rs) = @_;
# If we're a two-tier council show all problems on the map and not just
# those for this cobrand's council to reduce duplicate reports.
return $self->is_two_tier ? $rs : $self->problems_restriction($rs);
# (but still respect the cut-off date)
if ($self->is_two_tier) {
if (my $date = $self->cut_off_date) {
my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me';
$rs = $rs->search({
"$table.created" => { '>=', $date }
});
}
return $rs;
} else {
return $self->problems_restriction($rs);
}
}

sub report_can_have_text_only_notifcations {
Expand Down
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/Script/CSVExport.pm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ EOF
DECLARE csr CURSOR WITH HOLD FOR $sql_with SELECT $sql_select FROM "problem" "me" $sql_join
WHERE regexp_split_to_array("me"."bodies_str", ',') && ARRAY['$body_id']
$where_states
ORDER BY "me"."confirmed", "me"."id", "comments"."confirmed", "comments"."id";
ORDER BY "me"."confirmed", "me"."id", "comments"."confirmed", "comments"."id", "questionnaire"."whenanswered", "questionnaire"."id";
EOF
}

Expand Down Expand Up @@ -337,7 +337,7 @@ sub process_questionnaire {
my ($hashref, $obj) = @_;
my $new_state = $obj->{questionnaire_new_state} || '';
if ($fixed_states->{$new_state}) {
if (!$hashref->{fixed} || $obj->{comment_confirmed} lt $hashref->{fixed}) {
if (!$hashref->{fixed} || $obj->{questionnaire_whenanswered} lt $hashref->{fixed}) {
$hashref->{fixed} = $obj->{questionnaire_whenanswered};
}
}
Expand Down
35 changes: 24 additions & 11 deletions t/app/controller/waste_brent_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ sub new { my $c = shift; bless { @_ }, $c; }

package main;

sub garden_waste_no_bins {
return [ {
sub food_waste_collection {
return {
Id => 1001,
ServiceId => 316,
ServiceName => 'Food waste collection',
Expand All @@ -99,7 +99,13 @@ sub garden_waste_no_bins {
},
} ] },
} },
}, {
};
}

sub garden_waste_no_bins {
return [
food_waste_collection(),
{
# Eligibility for garden waste, but no task
Id => 1002,
ServiceId => 317,
Expand All @@ -109,21 +115,21 @@ sub garden_waste_no_bins {
}

sub garden_waste_one_sack {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(1, 'sack');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub garden_waste_one_bin {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(1, 'bin');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub garden_waste_two_bins {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(2, 'bin');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub _garden_waste_service_units {
Expand All @@ -135,7 +141,7 @@ sub _garden_waste_service_units {

my $bin_type_id = 1;

return [ {
return {
Id => 1002,
ServiceId => 317,
ServiceName => 'Garden waste collection',
Expand Down Expand Up @@ -167,7 +173,7 @@ sub _garden_waste_service_units {
Ref => { Value => { anyType => [ 567, 890 ] } },
},
} ] },
} } } ];
} } };
}

FixMyStreet::override_config {
Expand Down Expand Up @@ -324,6 +330,13 @@ FixMyStreet::override_config {
$mech->content_contains('Subscribe to Garden waste collection service', 'Subscribe link present if expired');
};

$echo->mock('GetServiceUnitsForObject', [ food_waste_collection() ]);
subtest 'check new sub bin limits' => sub {
$mech->get_ok('/waste/12345/garden');
is $mech->uri->path, '/waste/12345';
$mech->content_lacks('Subscribe to Garden waste collection service');
};

$echo->mock('GetServiceUnitsForObject', \&garden_waste_no_bins);
subtest 'check new sub bin limits' => sub {
$mech->get_ok('/waste/12345/garden');
Expand Down
17 changes: 14 additions & 3 deletions t/app/controller/waste_brent_small_items.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $body->set_extra_metadata(
item_list => [
{ bartec_id => '1', name => 'Tied bag of domestic batteries (min 10 - max 100)', max => '1' },
{ bartec_id => '2', name => 'Podback Bag' },
{ bartec_id => '3', name => 'Paint, up to 5 litres capacity (1 x 5 litre tin, 5 x 1 litre tins etc.)' },
{ bartec_id => '3', name => 'Paint, 1 can, up to 5 litres' },
{ bartec_id => '4', name => 'Textiles, up to 60 litres (one black sack / 3 carrier bags)' },
{ bartec_id => '5', name => 'Toaster', category => 'Small electrical items' },
{ bartec_id => '6', name => 'Kettle', category => 'Small electrical items' },
Expand Down Expand Up @@ -339,7 +339,7 @@ FixMyStreet::override_config {
for my $test (
{
items => &item_fields('Tied bag of domestic batteries (min 10 - max 100)', 'Toaster',
'Podback Bag', 'Paint, up to 5 litres capacity (1 x 5 litre tin, 5 x 1 litre tins etc.)' ),
'Podback Bag', 'Paint, 1 can, up to 5 litres' ),
content_contains => [$error_messages{categories}],
content_lacks => [$error_messages{weee}, $error_messages{peritem}]
},
Expand Down Expand Up @@ -461,7 +461,7 @@ FixMyStreet::override_config {
my $report_id = $report->id;
$report->update({ external_id => 'a-guid' });

# Fixed date still set to 5th July
# Fixed date still set to 25th June
$mech->get_ok('/waste/12345');
$mech->content_lacks('Report a small items collection as missed');
$mech->get_ok('/waste/12345/report');
Expand All @@ -477,6 +477,17 @@ FixMyStreet::override_config {
$mech->content_lacks('Report a small items collection as missed', 'Too long ago');
$mech->get_ok('/waste/12345/report');
$mech->content_lacks('Small items collection');
$echo->mock( 'GetEventsForObject', sub { [ {
Guid => 'a-guid',
EventTypeId => 2964,
} ] } );
ok set_fixed_time('2023-07-01T22:59:59Z'), 'Set current date to 1st July';
$mech->get_ok('/waste/12345');
$mech->content_lacks('Report a small items collection as missed', 'Can not report on due date when no resolution');
ok set_fixed_time('2023-07-02T05:44:59Z'), 'Set current date to 2nd July';
$mech->get_ok('/waste/12345');
$mech->content_contains('Report a small items collection as missed', 'Can report when due date passed and no resolution');
ok set_fixed_time('2023-06-25T05:44:59Z'), 'Reset current date to 25th June for consistency';
$echo->mock( 'GetEventsForObject', sub { [ {
Guid => 'a-guid',
EventTypeId => 2964,
Expand Down
30 changes: 29 additions & 1 deletion t/cobrand/surrey.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ $mech->create_contact_ok(body_id => $surrey->id, category => 'Potholes', email =
latitude => 51.293415, longitude => -0.441269, areas => '2242',
});

my $guildford = $mech->create_body_ok(2452, 'Guildford Borough Council');
$mech->create_contact_ok(body_id => $guildford->id, category => 'Flytipping', email => '[email protected]');

my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'surrey' ],
Expand Down Expand Up @@ -63,7 +66,32 @@ FixMyStreet::override_config {
$mech->get_ok("/dashboard?export=1");
$mech->content_contains('website,surrey,,2', 'CSV Subscriber number is 2 from pre-generated csv');
$mech->log_out_ok;
}
};

subtest 'Old reports are not shown on Surrey cobrand' => sub {
note 'A newly created report is shown on Surrey cobrand';
my $json = $mech->get_ok_json('/around?ajax=1&bbox=-0.45869262976076,51.28481314324,-0.42367370886232,51.302390882532');
is_deeply($json->{pins}, [
[ "51.293415", "-0.441269", "yellow", $report->id, $report->title, "", 'false' ],
], 'Problem is initially included in Surrey cobrand');

note 'Making the report predate the cut-off excludes it from Surrey cobrand';
my $dt = DateTime->new(year => 2024, month => 9, day => 1, hour => 12);
$report->update({
created => $dt,
confirmed => $dt,
});
$json = $mech->get_ok_json('/around?ajax=1&bbox=-0.45869262976076,51.28481314324,-0.42367370886232,51.302390882532');
is_deeply($json->{pins}, [], 'Problem is now excluded from Surrey cobrand');

note 'Borough reports are excluded from Surrey cobrand if old enough too.';
$report->update({
bodies_str => $guildford->id,
category => 'Flytipping',
});
$json = $mech->get_ok_json('/around?ajax=1&bbox=-0.45869262976076,51.28481314324,-0.42367370886232,51.302390882532');
is_deeply($json->{pins}, [], 'Borough problem is excluded from Surrey cobrand');
};
};


Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/waste/bulky/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<li>Textiles: Up to 3 - each one up to 60L (eg 3 carrier bags or one black bin bag)</li>
<li>Small electrical items: Up to 4 small electrical items</li>
<li>Batteries: 1 tied bag of domestic batteries (minimum of ten and maximum of 100)</li>
<li>Paint: Up to 4 - each item can be up to 5 litres of capacity (for example 1 x 5 litre tin or 5 x 1 litre tin), the maximum total for a booking is 20 litres of capacity</li>
<li>Paint: Up to 20 litres total capacity (no more than 4 tins maximum)</li>
</ul>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions templates/web/surrey/footer_extra.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@
</footer>
[% PROCESS '_footer_main_nav.html' %]
[% PROCESS '_footer_extra_powered_by.html' %]

<script type="text/javascript" src=https://feedback.happy-or-not.com/v1/bootloader/5D00DED5BC398A41C871E62A08F7CAC0/bootloaderjs/?lang=fi-FI&init=false></script>
<script type="text/javascript" nonce="[% csp_nonce %]"> window.HappyOrNot && window.HappyOrNot.init({ token: "5D00DED5BC398A41C871E62A08F7CAC0", embedTo: document.getElementById('happy-or-not-smiley-digital-embed') }); </script>
3 changes: 0 additions & 3 deletions templates/web/surrey/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
[% PROCESS 'footer_extra_js_base.html' highways=1 validation=1 %]

<script type="text/javascript" src=https://feedback.happy-or-not.com/v1/bootloader/5D00DED5BC398A41C871E62A08F7CAC0/bootloaderjs/?lang=fi-FI&init=false></script>
<script type="text/javascript" nonce="[% csp_nonce %]"> window.HappyOrNot && window.HappyOrNot.init({ token: "5D00DED5BC398A41C871E62A08F7CAC0", embedTo: document.getElementById('happy-or-not-smiley-digital-embed') }); </script>
3 changes: 3 additions & 0 deletions web/cobrands/sass/_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ $button_bg_col: #a1a1a1; // also search bar (tables)
h2 { // only really want on first-child
margin-top: 0;
}
.multi-select-button {
white-space: normal;
}
}

.admin-offsite-link {
Expand Down

0 comments on commit e052655

Please sign in to comment.