Goo

 view release on metacpan or  search on metacpan

lib/Goo/CareOMeter.pm  view on Meta::CPAN

package Goo::CareOMeter;

###############################################################################
# Nigel Hamilton
#
# Copyright Nigel Hamilton 2005
# All Rights Reserved
#
# Author:       Nigel Hamilton
# Filename:     Goo::CareOMeter.pm
# Description:  Keep a track of what I need to care about
#
# Date          Change
# -----------------------------------------------------------------------------
# 19/10/2005    Added method: getTableOfCare
# 25/10/2005    decided to add tasks and bugs on the same screen - but new
#               Things are coming: ideas, feedback, projects, events etc.
#
###############################################################################

use strict;

use Goo::Object;
use Goo::Profile;
use Goo::Loader;
use Goo::Prompter;
use Goo::Database;
use Text::FormatTable;

use base qw(Goo::Object);

# the size of the mental buffer
our $BUFFER_SIZE = 3;

###############################################################################
#
# get_bugs_table - return a table of bugs I care about
#
###############################################################################

sub get_bugs_table {

    my ($this, $profile) = @_;

    my $query = Goo::Database::execute_sql(<<EOSQL);
		
		select 		title, bugid, importance, 
					date_format(foundon, '%d %b %Y') as 'foundon', 
					description
		from 		bug
		where		status = 'alive'
		order by 	importance desc, foundon desc 
		limit		$BUFFER_SIZE

EOSQL

    my $full_text = "";

    # set up the table
    my $table = Text::FormatTable->new('4l 60l 6l 11l 18l');

    # column headings
    $table->head('', 'Bugs', 'BugID', 'Importance', 'Found On');
    $table->rule('-');

    while (my $row = Goo::Database::get_result_hash($query)) {

        my $index_key = $profile->get_next_index_key();

        $profile->add_option($index_key, "$row->{bugid}.bug", "Goo::ThingProfileOption");

        # print "addin conter === $counter \n";
        $table->row("[$index_key]",     $row->{title}, $row->{bugid},
                    $row->{importance}, $row->{foundon});
        $full_text .= $row->{title} . " " . $row->{description};

    }

    return (Goo::Prompter::highlight_options($table->render()), $full_text);

}

###############################################################################
#
# get_tasks_table - return a table of tasks I care about
#
###############################################################################

sub get_tasks_table {

    my ($this, $profile) = @_;

    my $query = Goo::Database::execute_sql(<<EOSQL);
		
		select 		taskid, title, description, importance,
					date_format(requestedon, '%d %b %Y') as 'requestedon'
		from 		task	
		where		status = 'pending'
		order by 	importance desc, requestedon desc 
		limit		$BUFFER_SIZE

EOSQL

    my $full_text = "";

    # set up the table
    my $table = Text::FormatTable->new('4l 60l 6l 11l 18l');

    # column headings
    $table->head('', 'Tasks', 'TaskID', 'Importance', 'Requested On');
    $table->rule('-');



( run in 2.924 seconds using v1.01-cache-2.11-cpan-14f38c9f855 )