Skip to content

Commit

Permalink
[Merton] Calendar with multiple services, same ID.
Browse files Browse the repository at this point in the history
Merton has textiles / batteries sharing the same as food waste.
  • Loading branch information
dracos committed Dec 4, 2024
1 parent f7cae7b commit d13e42b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions perllib/FixMyStreet/Roles/Cobrand/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,10 @@ sub bin_future_collections {
my $self = shift;

my $services = $self->{c}->stash->{service_data};
my @tasks;
my %names;
foreach (@$services) {
next unless $_->{service_task_id};
push @tasks, $_->{service_task_id};
$names{$_->{service_task_id}} = $_->{service_name};
push @{$names{$_->{service_task_id}}}, $_->{service_name};
}

my $start = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->truncate( to => 'day' );
Expand All @@ -630,15 +628,15 @@ sub bin_future_collections {

my $echo = $self->feature('echo');
$echo = Integrations::Echo->new(%$echo);
my $result = $echo->GetServiceTaskInstances($start, $end, @tasks);
my $result = $echo->GetServiceTaskInstances($start, $end, sort keys %names);

my $events = [];
foreach (@$result) {
my $task_id = $_->{ServiceTaskRef}{Value}{anyType};
my $tasks = Integrations::Echo::force_arrayref($_->{Instances}, 'ScheduledTaskInfo');
foreach (@$tasks) {
my $dt = construct_bin_date($_->{CurrentScheduledDate});
my $summary = $names{$task_id} . ' collection';
my $summary = join('/', @{$names{$task_id}}) . ' collection';
my $desc = '';
push @$events, { date => $dt, summary => $summary, desc => $desc };
}
Expand Down

0 comments on commit d13e42b

Please sign in to comment.