fix transaction list in admin and speed up external count

This commit is contained in:
Thomas Bloor 2019-09-09 16:42:49 +01:00
parent 962cf972da
commit d484b342df
No known key found for this signature in database
GPG Key ID: 4657C7EBE42CC5CC
2 changed files with 6 additions and 5 deletions

View File

@ -18,8 +18,8 @@ sub index {
{},
{
select => [
{ count => 'id', '-as' => 'count' },
{ sum => 'value', '-as' => 'sum_value' },
{ count => 'me.value', '-as' => 'count' },
{ sum => 'me.value', '-as' => 'sum_value' },
'quantised_weeks',
],
group_by => 'quantised_weeks',

View File

@ -199,14 +199,15 @@ sub post_supplier_count {
buyer_id => $user->entity->id,
},
{
prefetch => { 'seller' => 'organisation' },
join => { 'seller' => 'organisation' },
select => [
{ count => 'me.id', '-as' => 'count' },
{ sum => 'me.value', '-as' => 'total_spend' },
'organisation.name',
'me.quantised_days',
],
group_by => [ 'me.quantised_days', 'seller.id' ],
as => [ qw/ count total_spend name quantised_days / ],
group_by => [ qw/ me.quantised_days seller.id organisation.id / ],
order_by => { '-asc' => 'me.quantised_days' },
}
);
@ -216,7 +217,7 @@ sub post_supplier_count {
count => $_->get_column('count'),
value => ($_->get_column('total_spend') / 100000) // 0,
date => $_->get_column('quantised_days'),
seller => $_->seller->organisation->name,
seller => $_->get_column('name'),
}} $spend_rs->all,
);