[Bps-public-commit] r10969 - in RT-Extension-Reports: html/Reports/Types
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Mar 2 02:37:25 EST 2008
Author: sunnavy
Date: Sun Mar 2 02:37:23 2008
New Revision: 10969
Modified:
RT-Extension-Reports/html/Reports/Types/TicketsNumber
RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm
Log:
complete Filter.pm
Modified: RT-Extension-Reports/html/Reports/Types/TicketsNumber
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/TicketsNumber (original)
+++ RT-Extension-Reports/html/Reports/Types/TicketsNumber Sun Mar 2 02:37:23 2008
@@ -63,7 +63,7 @@
</tr>
<tr>
<td><&|/l&>Filter</&></td>
-<td><textarea name="Filter" cols="20" rows="5"><% $Filter %></textarea>
+<td><textarea name="Filter" cols="30" rows="5"><% $Filter %></textarea>
</tr>
<tr><td /><td>
<input type="hidden" name="Run" value=1>
@@ -128,10 +128,10 @@
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 );
+ my ( $field, $op, $value ) = split /\s+/, $_;
+ next TICKET unless RT::Extension::Reports::Filter::filter( Ticket
+ => $ticket, Value => $value, Operator => $op, Field =>
+ $field );
}
$output[int( ($ticket->CreatedObj->Unix - $start_date->Unix)/(3600*24)
)]->[1]++;
Modified: RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm
==============================================================================
--- RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm (original)
+++ RT-Extension-Reports/lib/RT/Extension/Reports/Filter.pm Sun Mar 2 02:37:23 2008
@@ -4,10 +4,86 @@
our @filters = qw/subject/;
-sub subject {
+my $map;
+
+# for ticket
+for (
+ qw/id Subject Status EffectiveId Queue Type IssueStatement Resolution
+ Owner InitialPriority FinalPriority Priority TimeEstimated TimeWorked
+ Creator Created LastUpdatedBy LastUpdated TimeLeft Told Starts Started Due Resolved/
+ )
+{
+ $map->{$_} = $_;
+}
+
+# for queue
+for (
+ qw/id Name Description CorrespondAddress CommentAddress InitialPriority
+ FinalPriority DefaultDueIn Creator Created LastUpdatedBy LastUpdated /
+ )
+{
+ $map->{QueueObj}{$_} = $_;
+}
+
+# for user
+$map->{OwnerObj} = $map->{LastUpdatedByObj} = $map->{CreatorObj} =
+ $map->{QueueObj}{CreatorObj} = $map->{QueueObj}{LastupdatedByObj} = {};
+
+for (
+ qw/id Name Comments EmailAddress FreeformContactInfo
+ Organization RealName NickName Lang
+ ExternalContactInfoId ContactInfoSystem ExternalAuthId AuthSysterm
+ Gecos HomePhone WorkPhone MobilePhone PagerPhone Address1 Address2
+ City State Zip Country Timezone/
+ )
+{
+ $map->{OwnerObj}{$_} = $_;
+}
+
+# for date
+
+for my $sub (
+ qw/Unix ISO Date GetWeekDay GetMonth Time W3CDTF AsString
+ AgeAsString/
+ )
+{
+ for (qw/Told Starts Started Due Resolved LastUpdated Created/) {
+ $map->{"${_}Obj"}{$sub} = $sub;
+ }
+
+ # for queue's date
+ for (qw/Created LastUpdated/) {
+ $map->{QueueObj}{"${_}Obj"}{$sub} = $sub;
+ }
+}
+
+sub filter {
my %args = @_;
return unless $args{Ticket};
- return _test( $args{Operator}, $args{Ticket}->Subject, $args{Value} );
+ return _test( $args{Operator}, _value( $args{Ticket}, $args{Field} ),
+ $args{Value} );
+}
+
+sub _value {
+ my $ticket = shift;
+ my $field = shift;
+ my @fields = split /\./, $field;
+
+ # check if we support that field
+ my $m = $map;
+ for my $f (@fields) {
+ $m = $m->{$f};
+ unless ( $m ) {
+ $RT::Logger->error( "$field not supported" );
+ return unless $m;
+ }
+ }
+
+ my $v = $ticket;
+ for my $f (@fields) {
+ $v = $v->$f;
+ }
+ return $v;
}
sub _test {
More information about the Bps-public-commit
mailing list