[Rt-commit] [rtir] 01/01: new constituency mechanism support for reporting
? sunnavy
sunnavy at bestpractical.com
Mon Mar 30 09:56:49 EDT 2015
This is an automated email from the git hooks/post-receive script.
sunnavy pushed a commit to branch 3.4/remove_old_constituencies_reporting
in repository rtir.
commit ea1493d4ffe94949d89ec2b9c999618e372a432d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Mar 30 21:41:42 2015 +0800
new constituency mechanism support for reporting
---
html/RTIR/Reporting/Report.html | 43 ++++++++++++++++++++++++++---------------
html/RTIR/Reporting/index.html | 19 ++++++++++++++----
2 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/html/RTIR/Reporting/Report.html b/html/RTIR/Reporting/Report.html
index 146b983..1c9d545 100644
--- a/html/RTIR/Reporting/Report.html
+++ b/html/RTIR/Reporting/Report.html
@@ -46,7 +46,12 @@
%#
%# END BPS TAGGED BLOCK }}}
<%PERL>
+if ( $Constituency ){
+ $m->comp("SELF:Heading$ReportAs", Text => loc('RTIR Periodic Report for [_1]', $Constituency) );
+}
+else{
$m->comp("SELF:Heading$ReportAs", Text => loc('RTIR Periodic Report') );
+}
$m->comp("SELF:TwoColumnsTable$ReportAs",
Body => [
@@ -110,14 +115,6 @@ my $get_incident_field = sub {
my $filter_by_incident_field = sub {
my ($tickets, $field, $condition) = (@_);
- my $res = {};
- unless ( ref $tickets eq 'HASH' ) {
- while ( my $t = $tickets->Next ) { $res->{ $t->Id } = $t }
- }
- else {
- %$res = %$tickets;
- }
-
while( my($id, $t) = each %$res ) {
my $value = $get_incident_field->( $t, $field );
@@ -160,31 +157,44 @@ my @classifications;
push @classifications, 'Unclassified';
}
+my $constituency_limit = $Constituency ? qq{ AND 'QueueCF.{RTIR Constituency}' = '$Constituency'} : '';
# of new reports outstanding at start of the period
my $outstanding = RT::Tickets->new( $session{'CurrentUser'} );
-$outstanding->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created < '$start' AND (Resolved = '1970-01-01 00:00:01' OR Resolved > '$start')");
-my $outstanding_pruned = $outstanding;
+$outstanding->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created < '$start' AND (Resolved = '1970-01-01 00:00:01' OR Resolved > '$start')" . $constituency_limit);
+my $outstanding_pruned;
+while ( my $t = $outstanding->Next ) {
+ $outstanding_pruned->{ $t->Id } = $t;
+}
# of new reports created during the period
my $tix_created = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_created->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created > '$start' AND Created < '$end'");
-my $tix_created_pruned = $tix_created;
+$tix_created->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created > '$start' AND Created < '$end'" . $constituency_limit);
+my $tix_created_pruned;
+while ( my $t = $tix_created->Next ) {
+ $tix_created_pruned->{ $t->Id } = $t;
+}
# of new reports resolved/closed/deleted during the period
# this means "number of reports created during the period that were
# also closed during the period(or before which is insane but possible)"
my $tix_resolved = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_resolved->FromSQL("Lifecycle = '".RT::IR->lifecycle_report. "' AND Created > '$start' AND Created < '$end' AND (Resolved > '1970-01-01 00:00:01' AND Resolved < '$end')");
-my $tix_resolved_pruned = $tix_resolved;
+$tix_resolved->FromSQL("Lifecycle = '".RT::IR->lifecycle_report. "' AND Created > '$start' AND Created < '$end' AND (Resolved > '1970-01-01 00:00:01' AND Resolved < '$end')" . $constituency_limit);
+my $tix_resolved_pruned;
+while ( my $t = $tix_resolved->Next ) {
+ $tix_resolved_pruned->{ $t->Id } = $t;
+}
# of new reports oustanding at end of the period
# this is "number of reports created during the period that were also
# closed during the period"
my $tix_unresolved = RT::Tickets->new( $session{'CurrentUser'} );
-$tix_unresolved->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created > '$start' AND Created < '$end' AND ( Resolved = '1970-01-01 00:00:01' OR Resolved > '$end' )");
-my $tix_unresolved_pruned = $tix_unresolved;
+$tix_unresolved->FromSQL("Lifecycle = '".RT::IR->lifecycle_report."' AND Created > '$start' AND Created < '$end' AND ( Resolved = '1970-01-01 00:00:01' OR Resolved > '$end' )" . $constituency_limit);
+my $tix_unresolved_pruned;
+while ( my $t = $tix_unresolved->Next ) {
+ $tix_unresolved_pruned->{ $t->Id } = $t;
+}
if ( $TextReport ) {
$r->content_type('text/plain');
@@ -196,6 +206,7 @@ if ( $TextReport ) {
<%ARGS>
$StartDate => undef
$EndDate => undef
+$Constituency => undef
$HTMLReport => 1
$TextReport => !$HTMLReport
$SpreadsheetReport => !($HTMLReport || $TextReport)
diff --git a/html/RTIR/Reporting/index.html b/html/RTIR/Reporting/index.html
index bab4270..bbccecd 100644
--- a/html/RTIR/Reporting/index.html
+++ b/html/RTIR/Reporting/index.html
@@ -51,6 +51,16 @@
<form action="index.html" method="post">
<table>
<tr>
+ <td class="label"><&|/l&>Constituency</&>:</td>
+ <td class="value">
+ <& /Elements/EditCustomField,
+ QueueObj => RT::Queue->new($session{CurrentUser}),
+ CustomField => $constituency_cf,
+ Name => 'Constituency',
+ &>
+ </td>
+ </tr>
+ <tr>
<td class="label"><&|/l&>Start Date:</&></td>
<td class="input">
<& /Elements/SelectDate, Name => 'StartDate', Default => $start->AsString &>
@@ -81,13 +91,14 @@
</form>
<%INIT>
-my $QueueObj = RT::Queue->new($session{'CurrentUser'});
-# XXX TODO port to new non-queue-name implementation
-$QueueObj->Load('Incidents');
-RT::Logger->error('Unable to load Incidents queue') unless $QueueObj->Id;
+my $constituency_cf = RT::CustomField->new($session{CurrentUser});
+$constituency_cf->Load('RTIR Constituency', LookupType => 'RT::Queue');
if ( $ARGS{'HTMLReport'} || $ARGS{'TextReport'} || $ARGS{'SpreadsheetReport'} ) {
+ $ARGS{'Constituency'} = delete $ARGS{ 'Object-RT::Queue--CustomField-'. $constituency_cf->Id .'-Values' };
+ delete $ARGS{ 'Object-RT::Queue--CustomField-'. $constituency_cf->Id .'-Values-Magic' };
+
my $ext = 'html';
$ext = 'txt' if $ARGS{'TextReport'};
$ext = 'tsv' if $ARGS{'SpreadsheetReport'};
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list