Compare commits
1 commit
developmen
...
iron59/ran
Author | SHA1 | Date | |
---|---|---|---|
|
f2acf705ee |
1 changed files with 12 additions and 10 deletions
|
@ -27,6 +27,7 @@ sub index {
|
||||||
/ );
|
/ );
|
||||||
|
|
||||||
return $c->api_validation_error if $validation->has_error;
|
return $c->api_validation_error if $validation->has_error;
|
||||||
|
|
||||||
if ($validation->param('graph') == 'total_range' || $validation->param('graph') == 'avg_spend_range') {
|
if ($validation->param('graph') == 'total_range' || $validation->param('graph') == 'avg_spend_range') {
|
||||||
$validation->required('start_date', 'end_date');
|
$validation->required('start_date', 'end_date');
|
||||||
}
|
}
|
||||||
|
@ -74,7 +75,7 @@ sub _purchases_total_duration {
|
||||||
my $data = { labels => [], data => [] };
|
my $data = { labels => [], data => [] };
|
||||||
|
|
||||||
# if $start_date and $end_date are not present it will use $duration
|
# if $start_date and $end_date are not present it will use $duration
|
||||||
my ( $start, $end ) = $c->_get_start_end_duration( $duration, $start_date, $end_date );
|
my ( $start, $end ) = $c->_get_start_end_duration( $duration, $start_date ? $start_date : 0, $end_date ? $end_Date : 0);
|
||||||
|
|
||||||
$data->{bounds} = {
|
$data->{bounds} = {
|
||||||
min => $c->format_iso_datetime( $start ),
|
min => $c->format_iso_datetime( $start ),
|
||||||
|
@ -122,7 +123,7 @@ sub _purchases_avg_spend_duration {
|
||||||
my $data = { labels => [], data => [] };
|
my $data = { labels => [], data => [] };
|
||||||
|
|
||||||
# if $start_date and $end_date are not present it will use $duration
|
# if $start_date and $end_date are not present it will use $duration
|
||||||
my ( $start, $end ) = $c->_get_start_end_duration( $duration, $start_date, $end_date );
|
my ( $start, $end ) = $c->_get_start_end_duration( $duration, $start_date ? $start_date : 0, $end_date ? $end_Date : 0);
|
||||||
|
|
||||||
$data->{bounds} = {
|
$data->{bounds} = {
|
||||||
min => $c->format_iso_datetime( $start ),
|
min => $c->format_iso_datetime( $start ),
|
||||||
|
@ -180,7 +181,7 @@ sub _get_start_end_duration {
|
||||||
my $start;
|
my $start;
|
||||||
my $end;
|
my $end;
|
||||||
|
|
||||||
if ($end_date && $start_date) {
|
if ($end_date != 0 && $start_date != 0) {
|
||||||
$start = DateTime->new(
|
$start = DateTime->new(
|
||||||
year => substr $start_date, 0, 4,
|
year => substr $start_date, 0, 4,
|
||||||
month => substr $start_date, 4, 2,
|
month => substr $start_date, 4, 2,
|
||||||
|
@ -192,7 +193,8 @@ sub _get_start_end_duration {
|
||||||
days => substr $end_date, 7, 2,
|
days => substr $end_date, 7, 2,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$end = $end->clone->subtract_duration( $duration );
|
$end = DateTime->today;
|
||||||
|
$start = $end->clone->subtract_duration( $duration );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( $start, $end );
|
return ( $start, $end );
|
||||||
|
|
Reference in a new issue