From: Mike Rylander Date: Tue, 30 Jun 2020 19:33:23 +0000 (-0400) Subject: LP#1885759: Count months and quarters across year boundaries X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3cbd3d76e094e1c8160c684922517431bcf10370;p=evergreen%2Fjoelewis.git LP#1885759: Count months and quarters across year boundaries We need to add year-multiples of months or quarters when using the months_ago or quarters_ago transforms in the reporter. Signed-off-by: Mike Rylander Signed-off-by: Rogan Hamby Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm b/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm index 0117d98bad..69eab42c24 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm @@ -740,7 +740,8 @@ package OpenILS::Reporter::SQLBuilder::Column::Transform::months_ago; sub toSQL { my $self = shift; - return 'EXTRACT(MONTH FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '"))'; + return '(EXTRACT(YEAR FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '")) * 12) +'. + ' EXTRACT(MONTH FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '"))'; } sub is_aggregate { return 0 } @@ -762,7 +763,8 @@ package OpenILS::Reporter::SQLBuilder::Column::Transform::quarters_ago; sub toSQL { my $self = shift; - return 'EXTRACT(QUARTER FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '"))'; + return '(EXTRACT(YEAR FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '")) * 4) +'. + ' EXTRACT(QUARTER FROM AGE(NOW(),"' . $self->{_relation} . '"."' . $self->name . '"))'; } sub is_aggregate { return 0 }