Skip to content

Commit

Permalink
[Bexley] Look up service description.
Browse files Browse the repository at this point in the history
Adds the service description to the report title, so
it's e.g. included in the template email.

https://mysocietysupport.freshdesk.com/a/tickets/4449
  • Loading branch information
MorayMySoc authored and dracos committed Sep 17, 2024
1 parent 2eb0466 commit 9768b68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1091,18 +1091,23 @@ sub waste_munge_report_data {

my $c = $self->{c};

my $address = $c->stash->{property}->{address};
my $service = $c->stash->{services}{$id}{service_name};
my $property = $c->stash->{property};
my $address = $property->{address};
my $service_id = $c->stash->{services}{$id}{service_id};
my $service_name = $c->stash->{services}{$id}{service_name};

Check warning on line 1097 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1094-L1097

Added lines #L1094 - L1097 were not covered by tests
my $uprn = $c->stash->{services}{$id}{uprn};
$data->{title} = "Report missed $service";
my $containers = $self->_containers($property);
my $service_description = $containers->{$service_id}->{description};

Check warning on line 1100 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1099-L1100

Added lines #L1099 - L1100 were not covered by tests
$service_description = 'Various' if $service_description =~ /<li>/;
$data->{title} = "$service_name ($service_description)";

Check warning on line 1102 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1102

Added line #L1102 was not covered by tests
$data->{detail} = "$data->{title}\n\n$address";
$c->set_param('uprn', $uprn);
$c->set_param('service_id', $id);
$c->set_param('location_of_containers', $data->{extra_detail}) if $data->{extra_detail};
$c->set_param('service_item_name', $c->stash->{services}{$id}{service_id});
$c->set_param('service_item_name', $service_id);

Check warning on line 1107 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1107

Added line #L1107 was not covered by tests

# Check if this property has assisted collections
my $contracts = $self->whitespace->GetSiteContracts($c->stash->{property}{uprn});
my $contracts = $self->whitespace->GetSiteContracts($property->{uprn});

Check warning on line 1110 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L1110

Added line #L1110 was not covered by tests
$c->set_param('assisted_yn', (grep { $_->{ContractID} == 7 } @$contracts) ? 'Yes' : 'No');
}

Expand Down
9 changes: 8 additions & 1 deletion t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Test::MockTime 'set_fixed_time';
use Test::Output;
use FixMyStreet::TestMech;
use FixMyStreet::Script::Reports;
use FixMyStreet::Script::Alerts;

FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }
Expand Down Expand Up @@ -846,7 +847,13 @@ FixMyStreet::override_config {
'Submitting missed collection report'
);
$mech->content_contains('Missed collection has been reported');

FixMyStreet::Script::Reports::send();
my @emails = $mech->get_email;
my $email;
for my $mail (@emails) {
$email = $mail->as_string if $mail->header('To') =~ '[email protected]';
};
like $email, qr/Brown Caddy \(Food waste\)/, 'Service added to title';
my @reports = FixMyStreet::DB->resultset("Problem")->all;
is @reports, 1, 'only one report created';

Expand Down
6 changes: 2 additions & 4 deletions templates/email/bexley/waste/_sidebar_content.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[% # Hacky string munging :-( %]
[% containers = cobrand.container_desc_for_template %]
[%
address = report.get_extra_metadata.property_address;
IF is_no_collections_enquiry;
title = report.detail;
title = title.remove(address);
ELSIF is_missed_collection;
title = report.title;
title = title.remove('Report missed ');
END
%]
<h2 style="[% h2_style %]">Bins reported as missed:</h2>
[% title | html_para_email(secondary_p_style) %]
[% report.title | html_para_email(secondary_p_style) %]
<br>
<h2 style="[% h2_style %]">Address:</h2>
[% address | html_para_email(secondary_p_style) %]

0 comments on commit 9768b68

Please sign in to comment.