[WTF CVS] wtf/lib/WTF Config.pm, 1.2, 1.3 Data.pm, 1.3, 1.4 Pages.pm, 1.4, 1.5 SQL.pm, 1.7, 1.8 Uti
Brought to you by:
gryphonshafer
|
From: Gryphon S. <gry...@us...> - 2006-12-02 00:09:14
|
Update of /cvsroot/wtf-tracker/wtf/lib/WTF In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv6361/lib/WTF Modified Files: Config.pm Data.pm Pages.pm SQL.pm Utils.pm Log Message: Random bits of changes here and there, mostly code clean-up but a few bits of refactoring (globally) based on a code review in prep for v1.02 build and release Index: SQL.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/SQL.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SQL.pm 28 Nov 2006 18:47:50 -0000 1.7 --- SQL.pm 2 Dec 2006 00:09:09 -0000 1.8 *************** *** 1,4 **** package WTF::SQL; ! our $VERSION = 1.01; use strict; use warnings; --- 1,4 ---- package WTF::SQL; ! our $VERSION = 1.02; use strict; use warnings; *************** *** 34,38 **** SELECT a.id AS authz_id, ! IF(ae.authz_id IS NULL, 0, 1) AS has_authz FROM authz AS a LEFT OUTER JOIN authz_employee AS ae --- 34,38 ---- SELECT a.id AS authz_id, ! IF( ae.authz_id IS NULL, 0, 1 ) AS has_authz FROM authz AS a LEFT OUTER JOIN authz_employee AS ae *************** *** 43,47 **** 'authz_ins' => q{ ! INSERT INTO authz_employee (employee_id, authz_id) VALUES (?, ?) }, --- 43,47 ---- 'authz_ins' => q{ ! INSERT INTO authz_employee ( employee_id, authz_id ) VALUES ( ?, ? ) }, *************** *** 102,106 **** SELECT work_day AS date, content AS notes, ! DATE_FORMAT(work_day, "%W, %M %e, %Y") AS work_day FROM notes WHERE employee_id = ? AND work_day BETWEEN ? AND ? --- 102,106 ---- SELECT work_day AS date, content AS notes, ! DATE_FORMAT( work_day, "%W, %M %e, %Y" ) AS work_day FROM notes WHERE employee_id = ? AND work_day BETWEEN ? AND ? *************** *** 109,113 **** 'notes_insup' => q{ ! INSERT INTO notes (employee_id, work_day, content) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE employee_id = ?, work_day = ?, content = ? }, --- 109,113 ---- 'notes_insup' => q{ ! INSERT INTO notes ( employee_id, work_day, content ) VALUES ( ?, ?, ? ) ON DUPLICATE KEY UPDATE employee_id = ?, work_day = ?, content = ? }, *************** *** 130,134 **** w.work_day, IF( c.name IS NULL AND w.hours IS NOT NULL, 'Non-Project Task', c.name ) AS codeline, ! IF( p.name IS NULL AND w.hours IS NOT NULL, t.name, CONCAT( p.name, ' (', t.name, ')' ) ) AS project, IF( p.bug IS NULL AND w.hours IS NOT NULL, 'NPT', p.bug ) AS bug, w.hours --- 130,138 ---- w.work_day, IF( c.name IS NULL AND w.hours IS NOT NULL, 'Non-Project Task', c.name ) AS codeline, ! IF( ! p.name IS NULL AND w.hours IS NOT NULL, ! t.name, ! CONCAT( p.name, ' (', t.name, ')' ) ! ) AS project, IF( p.bug IS NULL AND w.hours IS NOT NULL, 'NPT', p.bug ) AS bug, w.hours *************** *** 136,140 **** LEFT JOIN work AS w ON e.id = w.employee_id AND ! (w.work_day IS NULL OR w.work_day BETWEEN ? AND ?) LEFT JOIN project AS p ON w.project_id = p.id LEFT JOIN task AS t ON w.task_id = t.id --- 140,144 ---- LEFT JOIN work AS w ON e.id = w.employee_id AND ! ( w.work_day IS NULL OR w.work_day BETWEEN ? AND ? ) LEFT JOIN project AS p ON w.project_id = p.id LEFT JOIN task AS t ON w.task_id = t.id *************** *** 177,182 **** 'work_insup' => q{ ! INSERT INTO work (employee_id, work_day, project_id, task_id, hours, entered) ! VALUES (?, ?, ?, ?, ?, NOW()) ON DUPLICATE KEY UPDATE employee_id = ?, work_day = ?, project_id = ?, task_id = ?, hours = ?, entered = NOW() --- 181,186 ---- 'work_insup' => q{ ! INSERT INTO work ( employee_id, work_day, project_id, task_id, hours, entered ) ! VALUES ( ?, ?, ?, ?, ?, NOW() ) ON DUPLICATE KEY UPDATE employee_id = ?, work_day = ?, project_id = ?, task_id = ?, hours = ?, entered = NOW() *************** *** 201,205 **** p.id, p.name AS project, p.bug, COUNT(w.id) AS work_count, SUM(w.hours) AS hours_sum, ! COUNT(DISTINCT w.employee_id) AS employees_count, MIN(w.work_day) AS min_work_day, MAX(w.work_day) AS max_work_day FROM codeline AS c --- 205,209 ---- p.id, p.name AS project, p.bug, COUNT(w.id) AS work_count, SUM(w.hours) AS hours_sum, ! COUNT( DISTINCT w.employee_id ) AS employees_count, MIN(w.work_day) AS min_work_day, MAX(w.work_day) AS max_work_day FROM codeline AS c *************** *** 240,244 **** SELECT t.name AS task, SUM(w.hours) AS hours, ! COUNT(DISTINCT w.employee_id) AS employees, COUNT(w.id) AS entries FROM work AS w --- 244,248 ---- SELECT t.name AS task, SUM(w.hours) AS hours, ! COUNT( DISTINCT w.employee_id ) AS employees, COUNT(w.id) AS entries FROM work AS w *************** *** 369,373 **** =head1 VERSION ! This document describes WTF::SQL version 1.01 =head1 SYNOPSIS --- 373,377 ---- =head1 VERSION ! This document describes WTF::SQL version 1.02 =head1 SYNOPSIS Index: Pages.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Pages.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Pages.pm 20 Nov 2006 02:53:07 -0000 1.4 --- Pages.pm 2 Dec 2006 00:09:09 -0000 1.5 *************** *** 1,4 **** package WTF::Pages; ! our $VERSION = 1.01; use strict; use warnings; --- 1,4 ---- package WTF::Pages; ! our $VERSION = 1.02; use strict; use warnings; *************** *** 21,45 **** # the subclass to handle page generation DISPATCH_TABLE => { ! '/input' => [ 'Input', 'screen_input' ], ! '/input/projects' => [ 'Input', 'screen_input_projects' ], ! '/input/tasks' => [ 'Input', 'screen_input_tasks' ], ! '/input/tracking' => [ 'Input', 'screen_input_tracking' ], ! '/input/timesheet' => [ 'Input', 'action_input_save_timesheet' ], ! '/reports/myweekly' => [ 'Reports', 'screen_reports_myweekly' ], ! '/reports/team' => [ 'Reports', 'screen_reports_team_view' ], ! '/reports/projects' => [ 'Reports', 'screen_reports_projects_list' ], ! '/reports/project' => [ 'Reports', 'screen_reports_project_view' ], ! '/reports/activity' => [ 'Reports', 'screen_activity_summary' ], ! '/admin/authz' => [ 'Admin', 'screen_admin_authz' ], ! '/admin/newauthzs' => [ 'Admin', 'action_admin_save_new_authzs' ], ! '/admin/update' => [ 'Admin', 'action_admin_update' ], ! '/admin/users' => [ 'Admin', 'screen_admin_users' ], ! '/admin/saveusers' => [ 'Admin', 'action_admin_save_users' ], ! '/admin/taskarea' => [ 'Admin', 'screen_admin_task_area' ], ! '/admin/savetarea' => [ 'Admin', 'action_admin_save_task_area' ], ! '/admin/loginas' => [ 'Admin', 'action_login_as' ], ! '/admin/revert' => [ 'Admin', 'action_revert_to_self' ], ! '/admin/tables' => [ 'Admin', 'screen_table_data' ], ! '/admin/tablesave' => [ 'Admin', 'action_save_table_data' ], }, }; --- 21,45 ---- # the subclass to handle page generation DISPATCH_TABLE => { ! '/input' => [ 'Input', 'screen_input' ], ! '/input/projects' => [ 'Input', 'screen_projects' ], ! '/input/tasks' => [ 'Input', 'screen_tasks' ], ! '/input/tracking' => [ 'Input', 'screen_tracking' ], ! '/input/timesheet' => [ 'Input', 'action_save_timesheet' ], ! '/reports/myweekly' => [ 'Reports', 'screen_myweekly' ], ! '/reports/team' => [ 'Reports', 'screen_team_view' ], ! '/reports/projects' => [ 'Reports', 'screen_projects_list' ], ! '/reports/project' => [ 'Reports', 'screen_project_view' ], ! '/reports/activity' => [ 'Reports', 'screen_activity_summary' ], ! '/admin/authz' => [ 'Admin', 'screen_authz' ], ! '/admin/newauthzs' => [ 'Admin', 'action_save_new_authzs' ], ! '/admin/update' => [ 'Admin', 'action_update' ], ! '/admin/users' => [ 'Admin', 'screen_users' ], ! '/admin/saveusers' => [ 'Admin', 'action_save_users' ], ! '/admin/taskarea' => [ 'Admin', 'screen_task_area' ], ! '/admin/savetarea' => [ 'Admin', 'action_save_task_area' ], ! '/admin/loginas' => [ 'Admin', 'action_login_as' ], ! '/admin/revert' => [ 'Admin', 'action_revert_to_self' ], ! '/admin/tables' => [ 'Admin', 'screen_table_data' ], ! '/admin/tablesave' => [ 'Admin', 'action_save_table_data' ], }, }; *************** *** 90,94 **** =head1 VERSION ! This document describes WTF::Pages version 1.01 =head1 SYNOPSIS --- 90,94 ---- =head1 VERSION ! This document describes WTF::Pages version 1.02 =head1 SYNOPSIS Index: Data.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Data.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Data.pm 27 Oct 2006 22:34:51 -0000 1.3 --- Data.pm 2 Dec 2006 00:09:09 -0000 1.4 *************** *** 120,124 **** =head1 VERSION ! This document describes WTF::Data version 1.01 =head1 SYNOPSIS --- 120,124 ---- =head1 VERSION ! This document describes WTF::Data version 1.02 =head1 SYNOPSIS *************** *** 263,271 **** =back - =head1 KNOWN ISSUES - - There have been occational problems with notes not displaying correctly. These - bugs have been fixed and verified, but there may be some left to be discovered. - =head1 COPYRIGHT, LICENSE, AND DISCLAIMER OF WARRANTY --- 263,266 ---- Index: Config.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Config.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Config.pm 28 Nov 2006 18:54:13 -0000 1.2 --- Config.pm 2 Dec 2006 00:09:09 -0000 1.3 *************** *** 1,4 **** package WTF::Config; ! our $VERSION = 1.01; use strict; use warnings; --- 1,4 ---- package WTF::Config; ! our $VERSION = 1.02; use strict; use warnings; *************** *** 72,76 **** 'email' => { 'wtf' => 'wt...@ex...', ! 'admin' => 'gsh...@ex...', 'server' => 'mail.example.com', }, --- 72,76 ---- 'email' => { 'wtf' => 'wt...@ex...', ! 'admin' => 'ad...@ex...', 'server' => 'mail.example.com', }, *************** *** 95,99 **** =head1 VERSION ! This document describes WTF::Config version 1.01 =head1 SYNOPSIS --- 95,99 ---- =head1 VERSION ! This document describes WTF::Config version 1.02 =head1 SYNOPSIS *************** *** 137,144 **** =back - =head1 KNOWN ISSUES - - No bugs have been reported. - =head1 COPYRIGHT, LICENSE, AND DISCLAIMER OF WARRANTY --- 137,140 ---- Index: Utils.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Utils.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Utils.pm 27 Oct 2006 22:34:51 -0000 1.3 --- Utils.pm 2 Dec 2006 00:09:09 -0000 1.4 *************** *** 224,227 **** --- 224,281 ---- } + sub indent { + my ( $table_data, $indent_key, $function ) = @_; + return $table_data if ( not $indent_key ); + my ( $indent, @rows, @last_ids, @seen_ids ) = ( 0 ); + + for ( @{$table_data} ) { + push @seen_ids, $_->{'id'} || 0; + my $id = $_->{$indent_key}; + + # if there's no indent key, then the item should have no intent + if ( not $_->{$indent_key} or not grep { $_ == $id } @seen_ids ) { + $indent = 0; + @last_ids = (); + } + + # increment the items indent if the indent key is not the same + # as the previous parent_id + elsif ( + @rows and + $_->{$indent_key} != ( $last_ids[-1] || -1 ) + ) { + + # this id is in the id stack, so decrement indent and + # pop ids off the stack until a match or at empty + if ( grep { $_ == $id } @last_ids ) { + do { + $indent--; + pop @last_ids; + } while ( $last_ids[-1] ne $id and @last_ids ); + } + + # this is an id that's not in the stack, so increment indent + # and push the id onto the stack + else { + $indent++; + push @last_ids, $_->{$indent_key}; + } + } + $_->{'indent'} = $indent; + + # "group" denotes that the item is unselectable by the user, that the + # item is a group name, not a task name + $rows[-1]->{'group'} = 1 if ( + @rows and defined $_->{$indent_key} and + $_->{$indent_key} == ( $rows[-1]->{'id'} || -1 ) + ); + + $function->($_) if ( $function and ref($function) eq 'CODE' ); + push @rows, $_; + } + + return \@rows; + } + 1; __END__ *************** *** 263,266 **** --- 317,326 ---- ); + my @indented_data = @{ WTF::Utils::indent( + $sth->{'data'}->fetchall_arrayref({}), + 'parent_id', + \&function, + ); + =head1 DESCRIPTION *************** *** 573,576 **** --- 633,670 ---- any HTML markup in the note content. + =head2 indent() + + This function requires a reference to a data structure similar to what would + be returned from a "$sth->fetchall_arrayref({})" call. It also requires a + "indent key" (a column within each row that is typically a foreign key to + the primary key of the same table). + + my @indented_data = @{ WTF::Utils::indent( + $sth->{'data'}->fetchall_arrayref({}), + 'parent_id', + ); + + The function returns a reference to an array that is structurally similar to + the "$sth->fetchall_arrayref({})" input, but each row will contain an + additional key called "indent" that will contain an integer starting at 0 + indicating how many indent levels at which the particular row should be + displayed. Each row may also contain a "group" key containing a boolean that + indicates whether the row is a group, meaning that it has items "below" it + that are children. + + The function will optionally take a third argument, which is a reference to + a function that will run against each row on that row's data after the + indent level is assigned. The anonymous function will get passed a reference + to the row of data (a reference to a hash). + + my @indented_data = @{ WTF::Utils::indent( + $sth->{'data'}->fetchall_arrayref({}), + 'parent_id', + sub { + my ($row) = @_; + $row->{'indent_plus_five'} = $row->{'indent'} + 5; + }, + ); + =head1 DEPENDENCIES |