Compare commits

...
This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.

1 commit

Author SHA1 Message Date
Finn
3fa8534431 fixed week display 2018-08-24 15:22:59 +01:00

View file

@ -93,9 +93,23 @@ sub post_customer {
} }
); );
use Devel::Dwarn;
my $date_formatter = DateTime::Format::Strptime->new(
pattern => '%Y-%m-%d %H-%M-%S'
);
my @all_weeks = $week_transaction_rs->all; my @all_weeks = $week_transaction_rs->all;
my $first = defined $all_weeks[0] ? $all_weeks[0]->get_column('count') || 0 : 0; my ( $first, $second ) = (0,0);
my $second = defined $all_weeks[1] ? $all_weeks[1]->get_column('count') || 0 : 0; my $this_week_object = $end->truncate( to => 'week' );
my $this_week = $date_formatter->parse_datetime($this_week_object);
if ($all_weeks[0]->get_column('quantised') eq $this_week) {
$first = defined $all_weeks[0] ? $all_weeks[0]->get_column('count') || 0 : 0;
}
my $last_week = $date_formatter->parse_datetime($this_week_object->subtract( weeks => 1 ));
if (defined $all_weeks[1] && $all_weeks[1]->get_column('quantised') eq $last_week) {
$second = defined $all_weeks[1] ? $all_weeks[1]->get_column('count') || 0 : 0;
}
my $max = max( map { $_->get_column('count') } @all_weeks ); my $max = max( map { $_->get_column('count') } @all_weeks );
my $sum = sum( map { $_->get_column('count') } @all_weeks ); my $sum = sum( map { $_->get_column('count') } @all_weeks );
my $count = $week_transaction_rs->count; my $count = $week_transaction_rs->count;