[Rt-commit] rt branch, 4.4/user-time-worked, repushed

Craig Kaiser craig at bestpractical.com
Fri Jul 6 09:48:26 EDT 2018


The branch 4.4/user-time-worked was deleted and repushed:
       was 97e0a63b76074bdf31729e38399e2f2632dc69a8
       now fa5f41800f8e4eb31a94a07741f140a5f6d1fba7

1: dd5257b50 ! 1: fa5f41800 Create a RT time worked report by user
    @@ -1,4 +1,4 @@
    -Author: craig Kaiser <craig at bestpractical.com>
    +Author: Craig Kaiser <craig at bestpractical.com>
     
         Create a RT time worked report by user
         
    @@ -39,83 +39,6 @@
     new file mode 100644
     --- /dev/null
     +++ b/share/html/Helpers/UserTime
    -@@
    -+<%INIT>
    -+if ( $user_req && $start_date && $end_date ) {
    -+    my $user = RT::User->new( $session{CurrentUser} );
    -+
    -+    my ($ret, $msg) = $user->Load( $user_req );
    -+    return ($ret, $msg) unless $ret;
    -+
    -+    my $start = RT::Date->new( $session{CurrentUser} );
    -+    $ret = $start->Set( Value => $start->ParseByTimeParseDate(Value => $start_date, Timezone => 'user') );
    -+    return $ret unless $ret;
    -+
    -+    my $end = RT::Date->new($session{CurrentUser});
    -+    $ret = $end->Set( Value => $end->ParseByTimeParseDate(Value => $end_date, Timezone => 'user') );
    -+    return $ret unless $ret;
    -+
    -+    my $txns = RT::Transactions->new($session{CurrentUser});
    -+    $txns->Limit(
    -+        FIELD    => 'ObjectType',
    -+        VALUE    => 'RT::Ticket',
    -+    );
    -+
    -+    $txns->Limit(
    -+        FIELD    => 'Creator',
    -+        VALUE    => $user->id,
    -+    );
    -+
    -+    $txns->Limit(
    -+        FIELD    => 'TimeTaken',
    -+        VALUE    => 0,
    -+        OPERATOR => '!=',
    -+    );
    -+
    -+    $txns->Limit(
    -+        FIELD    => 'Created',
    -+        VALUE    => $start->ISO(Timezone => 'user'),
    -+        OPERATOR => '>=',
    -+    );
    -+
    -+    $txns->Limit(
    -+        FIELD    => 'Created',
    -+        VALUE    => $end->ISO(Timezone => 'user'),
    -+        OPERATOR => '<=',
    -+        ENTRYAGGREGATOR => 'AND',
    -+    );
    -+
    -+    my %data;
    -+    my $total_time_worked = 0;
    -+    while ( my $txn = $txns->Next ) {
    -+        my $ticket = $txn->TicketObj;
    -+        $total_time_worked = $total_time_worked + $txn->TimeTaken;
    -+
    -+        my $day_worked = $txn->CreatedObj->RFC2822( Time => 0, Timezone => 'user' );
    -+        my $time_hours = $txn->TimeTaken / 60;
    -+
    -+        push @{$data{$day_worked}}, {DayWorked => $day_worked, Id => $ticket->Id, Subject => $ticket->Subject, Queue => $ticket->QueueObj->Name,
    -+            Status => $ticket->Status, Owner => $ticket->OwnerObj->Name, Time => $time_hours > 1 ? $time_hours . ' hours (' . $txn->TimeTaken . '  minutes)' : $txn->TimeTaken . ' (minutes)',
    -+                TimeMin => $txn->TimeTaken};
    -+    }
    -+
    -+    $r->content_type('application/json; charset=utf-8');
    -+    $m->print(JSON({ TotalTime => $total_time_worked, data => \%data }));
    -+}
    -+
    -+$m->abort();
    -+</%INIT>
    -+
    -+<%ARGS>
    -+$user_req   =>   undef
    -+$start_date =>   undef
    -+$end_date   =>   undef
    -+</%ARGS>
    -
    -diff --git a/share/html/Tools/UserTime.html b/share/html/Tools/UserTime.html
    -new file mode 100644
    ---- /dev/null
    -+++ b/share/html/Tools/UserTime.html
     @@
     +%# BEGIN BPS TAGGED BLOCK {{{
     +%#
    @@ -164,9 +87,143 @@
     +%# those contributions and any derivatives thereof.
     +%#
     +%# END BPS TAGGED BLOCK }}}
    ++<%INIT>
    ++my @results;
    ++if ( $user_req && $start_date && $end_date ) {
    ++    my $user = RT::User->new( $session{CurrentUser} );
    ++
    ++    my ($ret, $msg) = $user->Load( $user_req );
    ++    push @results, $msg unless $ret;
    ++
    ++    my $start = RT::Date->new( $session{CurrentUser} );
    ++    $ret = $start->Set( Value => $start->ParseByTimeParseDate(Value => $start_date, Timezone => 'user') );
    ++    push @results, 'Invalid start date: ' . $start_date unless $ret;
    ++
    ++    my $end = RT::Date->new($session{CurrentUser});
    ++    ($ret, $msg) = $end->Set( Value => $end->ParseByTimeParseDate(Value => $end_date, Timezone => 'user') );
    ++    push @results, 'Invalid end date: ' . $end_date unless $ret;
    ++
    ++    my $txns = RT::Transactions->new($session{CurrentUser});
    ++    $txns->Limit(
    ++        FIELD    => 'ObjectType',
    ++        VALUE    => 'RT::Ticket',
    ++    );
    ++
    ++    $txns->Limit(
    ++        FIELD    => 'Creator',
    ++        VALUE    => $user->id,
    ++    );
    ++
    ++    $txns->Limit(
    ++        FIELD    => 'TimeTaken',
    ++        VALUE    => 0,
    ++        OPERATOR => '!=',
    ++    );
    ++
    ++    $txns->Limit(
    ++        FIELD    => 'Created',
    ++        VALUE    => $start->ISO(Timezone => 'user'),
    ++        OPERATOR => '>=',
    ++    );
    ++
    ++    $txns->Limit(
    ++        FIELD    => 'Created',
    ++        VALUE    => $end->ISO(Timezone => 'user'),
    ++        OPERATOR => '<=',
    ++        ENTRYAGGREGATOR => 'AND',
    ++    );
    ++
    ++    my %data;
    ++    my $total_time_worked = 0;
    ++    while ( my $txn = $txns->Next ) {
    ++        my $ticket = $txn->TicketObj;
    ++        $total_time_worked = $total_time_worked + $txn->TimeTaken;
    ++
    ++        my $day_worked = $txn->CreatedObj->RFC2822( Time => 0, Timezone => 'user' );
    ++        my $time_hours = $txn->TimeTaken / 60;
    ++
    ++        # We only want two decimal places
    ++        $time_hours = int($time_hours * (10**2)) / 10**2;
    ++
    ++        push @{$data{$day_worked}}, {DayWorked => $day_worked, Id => $ticket->Id, Subject => $ticket->Subject, Queue => $ticket->QueueObj->Name,
    ++            Status => $ticket->Status, Owner => $ticket->OwnerObj->Name, Time => $time_hours > 1 ? $time_hours . ' hours (' . $txn->TimeTaken . '  minutes)' : $txn->TimeTaken . ' (minutes)',
    ++                TimeMin => $txn->TimeTaken};
    ++    }
    ++
    ++    $r->content_type('application/json; charset=utf-8');
    ++    $m->print(JSON({ TotalTime => $total_time_worked, Data => \%data, Results => \@results }));
    ++}
    ++
    ++$m->abort();
    ++</%INIT>
    ++
    ++<%ARGS>
    ++$user_req   =>   undef
    ++$start_date =>   undef
    ++$end_date   =>   undef
    ++</%ARGS>
    +
    +diff --git a/share/html/Tools/UserTime.html b/share/html/Tools/UserTime.html
    +new file mode 100644
    +--- /dev/null
    ++++ b/share/html/Tools/UserTime.html
    +@@
    ++%# BEGIN BPS TAGGED BLOCK {{{
    ++%#
    ++%# COPYRIGHT:
    ++%#
    ++%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
    ++%#                                          <sales at bestpractical.com>
    ++%#
    ++%# (Except where explicitly superseded by other copyright notices)
    ++%#
    ++%#
    ++%# LICENSE:
    ++%#
    ++%# This work is made available to you under the terms of Version 2 of
    ++%# the GNU General Public License. A copy of that license should have
    ++%# been provided with this software, but in any event can be snarfed
    ++%# from www.gnu.org.
    ++%#
    ++%# This work is distributed in the hope that it will be useful, but
    ++%# WITHOUT ANY WARRANTY; without even the implied warranty of
    ++%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    ++%# General Public License for more details.
    ++%#
    ++%# You should have received a copy of the GNU General Public License
    ++%# along with this program; if not, write to the Free Software
    ++%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    ++%# 02110-1301 or visit their web page on the internet at
    ++%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
    ++%#
    ++%#
    ++%# CONTRIBUTION SUBMISSION POLICY:
    ++%#
    ++%# (The following paragraph is not intended to limit the rights granted
    ++%# to you to modify and distribute this software under the terms of
    ++%# the GNU General Public License and is only of importance to you if
    ++%# you choose to contribute your changes and enhancements to the
    ++%# community by submitting them to Best Practical Solutions, LLC.)
    ++%#
    ++%# By intentionally submitting any modifications, corrections or
    ++%# derivatives to this work, or any other work intended for use with
    ++%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
    ++%# you are the copyright holder for those contributions and you grant
    ++%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
    ++%# royalty-free, perpetual, license to use, copy, create derivative
    ++%# works based on those contributions, and sublicense and distribute
    ++%# those contributions and any derivatives thereof.
    ++%#
    ++%# END BPS TAGGED BLOCK }}}
     +<& /Elements/Header, Title => loc("User Time Worked") &>
     +<& /Elements/Tabs &>
    -+<& /Elements/ListActions, actions => \@results &>
    ++
    ++<div class="results" id="user-time-worked-results-container" style="display: none">
    ++    <&| /Widgets/TitleBox, title => loc('Results') &>
    ++    <ul class="action-results" id="user-time-worked-results">
    ++    </ul>
    ++    </&>
    ++</div>
     +
     +<div class="user-timeworked-form-content">
     +    <form onsubmit="event.preventDefault(); LoadUserTimeWorked()">
    @@ -189,10 +246,6 @@
     +    </form>
     +</div>
     +<div id='user-time-worked-content'></div>
    -+
    -+<%ARGS>
    -+ at results => undef
    -+</%ARGS>
     
     diff --git a/share/static/css/base/forms.css b/share/static/css/base/forms.css
     --- a/share/static/css/base/forms.css
    @@ -226,9 +279,20 @@
     +        dataType: "json",
     +        data: data,
     +        success: function( ARGS ) {
    -+            var data = ARGS['data'];
    ++            var data = ARGS['Data'];
     +            var keysArr = Object.keys(data).sort();
     +            var Content = jQuery('#user-time-worked-content');
    ++            var Results = jQuery('#user-time-worked-results');
    ++            var Results_container = jQuery('#user-time-worked-results-container');
    ++
    ++            Results.html("");
    ++            for (var i=0; i < ARGS['Results'].length; i++) {
    ++                Results.append('<li>' + ARGS['Results'][i] + '</li>');
    ++            }
    ++
    ++            if ( ARGS['Results'].length > 0 ) {
    ++                Results_container.show();
    ++            }
     +
     +            keysArr.forEach(function(key){
     +                var days = data[key];
    @@ -268,4 +332,3 @@
     +        },
     +    });
     +}
    -
2: 97e0a63b7 < -:  ------- Add BPS tagged block



More information about the rt-commit mailing list