Change to using a name map temporarily

This commit is contained in:
Tom Bloor 2019-07-15 03:45:42 +01:00
parent 546193f0cb
commit 4fdff21f50
No known key found for this signature in database
GPG key ID: 4657C7EBE42CC5CC
2 changed files with 20 additions and 57 deletions

View file

@ -198,12 +198,31 @@ sub post_supplier_count {
}
);
my $name_rs = $c->schema->resultset('Transaction')->search(
{
'me.buyer_id' => $user->entity->id,
},
{
prefetch => { entity => 'organisation' },
columns => [
'organisation.name',
'entity.id'
]
}
);
my %name_map = (
map {
$_->entity->id => $_->entity->organisation->name,
} $name_rs->all
);
my @graph_data = (
map { {
count => $_->get_column('count'),
value => $_->get_column('total_spend'),
date => $_->get_column('quantised'),
seller => $_->seller->name,
seller => %name_map{ $_->get_column('seller_id') },
} } $spend_rs->all,
);