[Bps-public-commit] r10967 - in RT-Extension-Reports: html/Reports/Types
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sat Mar 1 01:53:25 EST 2008
Author: sunnavy
Date: Sat Mar 1 01:53:22 2008
New Revision: 10967
Added:
RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm
Modified:
RT-Extension-Reports/html/Reports/Types/TicketsNumber
Log:
FromSQL doesn't work well, we have to make our own filters
Modified: RT-Extension-Reports/html/Reports/Types/TicketsNumber
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/TicketsNumber (original)
+++ RT-Extension-Reports/html/Reports/Types/TicketsNumber Sat Mar 1 01:53:22 2008
@@ -108,8 +108,9 @@
$end_date->AddDay; # we want the date ranage to be inclusive
my $tickets = RT::Tickets->new( $session{CurrentUser} );
+
$tickets->FromSQL( q{ Created >= '} . $start_date->ISO . q{ ' AND
-Created < '} . $end_date->ISO . q{'} . qq{ AND ( $Filter ) } );
+Created < '} . $end_date->ISO . q{'} );
my $tmp_date = RT::Date->new( $session{CurrentUser} );
$tmp_date->Set( Value => $start_date->Unix );
@@ -118,7 +119,20 @@
$tmp_date->AddDay;
}
+ TICKET:
while ( my $ticket = $tickets->Next ) {
+ require RT::Extension::Reports::Filter;
+ $Filter =~ s/\r\n/\n/g;
+ $Filter =~ s/\r/\n/g;
+ my @filters = split /\n+/, $Filter;
+ for ( @filters ) {
+ next unless /\S/;
+ s/^\s+//;
+ my ( $sub, $op, $value ) = split /\s+/, $_;
+ no strict 'refs';
+ $sub = "RT::Extension::Reports::Filter::$sub";
+ next TICKET unless $sub->( Ticket => $ticket, Value => $value, Operator => $op );
+ }
$output[int( ($ticket->CreatedObj->Unix - $start_date->Unix)/(3600*24)
)]->[1]++;
}
Added: RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm
==============================================================================
--- (empty file)
+++ RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm Sat Mar 1 01:53:22 2008
@@ -0,0 +1,112 @@
+package RT::Extension::Reports::Filter;
+use strict;
+use warnings;
+
+our @filters = qw/subject/;
+
+sub subject {
+ my %args = @_;
+ return unless $args{Ticket};
+ return _test( $args{Operator}, $args{Ticket}->Subject, $args{Value} );
+}
+
+sub _test {
+ my ( $op, $m, $n ) = @_;
+ if ( $op eq 'eq' ) {
+ return 1 if $m eq $n;
+ }
+ elsif ( $op eq 'ne' ) {
+ return 1 if $m ne $n;
+ }
+ elsif ( $op eq 'gt' ) {
+ return 1 if $m gt $n;
+ }
+ elsif ( $op eq 'ge' ) {
+ return 1 if $m ge $n;
+ }
+ elsif ( $op eq 'lt' ) {
+ return 1 if $m lt $n;
+ }
+ elsif ( $op eq 'le' ) {
+ return 1 if $m le $n;
+ }
+ elsif ( $op eq '==' ) {
+ return 1 if $m == $n;
+ }
+ elsif ( $op eq '!=' ) {
+ return 1 if $m != $n;
+ }
+ elsif ( $op eq '>' ) {
+ return 1 if $m > $n;
+ }
+ elsif ( $op eq '>=' ) {
+ return 1 if $m >= $n;
+ }
+ elsif ( $op eq '<' ) {
+ return 1 if $m < $n;
+ }
+ elsif ( $op eq '<=' ) {
+ return 1 if $m <= $n;
+ }
+ elsif ( $op eq '=~' ) {
+ return 1 if $m =~ /$n/;
+ }
+ elsif ( $op eq '!~' ) {
+ return 1 if $m !~ /$n/;
+ }
+
+ return 0;
+}
+
+1;
+
+=head1 NAME
+
+RT::Extension::Reports::Filter - Filter for RT Reports
+
+
+=head1 SYNOPSIS
+
+ use RT::Extension::Reports::Filter;
+
+
+=head1 DESCRIPTION
+
+
+=head1 AUTHOR
+
+sunnavy C<< <sunnavy at bestpractical.com> >>
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2007, Best Practical Solutions, LLC. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
+
+=head1 DISCLAIMER OF WARRANTY
+
+BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
+THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+=cut
+
More information about the Bps-public-commit
mailing list