line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::CareOMeter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::CareOMeter.pm |
11
|
|
|
|
|
|
|
# Description: Keep a track of what I need to care about |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 19/10/2005 Added method: getTableOfCare |
16
|
|
|
|
|
|
|
# 25/10/2005 decided to add tasks and bugs on the same screen - but new |
17
|
|
|
|
|
|
|
# Things are coming: ideas, feedback, projects, events etc. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5626
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
7
|
use Goo::Object; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
24
|
1
|
|
|
1
|
|
612
|
use Goo::Profile; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
143
|
|
25
|
1
|
|
|
1
|
|
7
|
use Goo::Loader; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
26
|
1
|
|
|
1
|
|
6
|
use Goo::Prompter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
27
|
1
|
|
|
1
|
|
6
|
use Goo::Database; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
28
|
1
|
|
|
1
|
|
6
|
use Text::FormatTable; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
6
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
858
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# the size of the mental buffer |
33
|
|
|
|
|
|
|
our $BUFFER_SIZE = 3; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
############################################################################### |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# get_bugs_table - return a table of bugs I care about |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
############################################################################### |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_bugs_table { |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
my ($this, $profile) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $query = Goo::Database::execute_sql(<<EOSQL); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
select title, bugid, importance, |
48
|
|
|
|
|
|
|
date_format(foundon, '%d %b %Y') as 'foundon', |
49
|
|
|
|
|
|
|
description |
50
|
|
|
|
|
|
|
from bug |
51
|
|
|
|
|
|
|
where status = 'alive' |
52
|
|
|
|
|
|
|
order by importance desc, foundon desc |
53
|
|
|
|
|
|
|
limit $BUFFER_SIZE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
EOSQL |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $full_text = ""; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# set up the table |
60
|
0
|
|
|
|
|
|
my $table = Text::FormatTable->new('4l 60l 6l 11l 18l'); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# column headings |
63
|
0
|
|
|
|
|
|
$table->head('', 'Bugs', 'BugID', 'Importance', 'Found On'); |
64
|
0
|
|
|
|
|
|
$table->rule('-'); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
while (my $row = Goo::Database::get_result_hash($query)) { |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $index_key = $profile->get_next_index_key(); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$profile->add_option($index_key, "$row->{bugid}.bug", "Goo::ThingProfileOption"); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# print "addin conter === $counter \n"; |
73
|
0
|
|
|
|
|
|
$table->row("[$index_key]", $row->{title}, $row->{bugid}, |
74
|
|
|
|
|
|
|
$row->{importance}, $row->{foundon}); |
75
|
0
|
|
|
|
|
|
$full_text .= $row->{title} . " " . $row->{description}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return (Goo::Prompter::highlight_options($table->render()), $full_text); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
############################################################################### |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# get_tasks_table - return a table of tasks I care about |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
############################################################################### |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub get_tasks_table { |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
1
|
|
my ($this, $profile) = @_; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $query = Goo::Database::execute_sql(<<EOSQL); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
select taskid, title, description, importance, |
96
|
|
|
|
|
|
|
date_format(requestedon, '%d %b %Y') as 'requestedon' |
97
|
|
|
|
|
|
|
from task |
98
|
|
|
|
|
|
|
where status = 'pending' |
99
|
|
|
|
|
|
|
order by importance desc, requestedon desc |
100
|
|
|
|
|
|
|
limit $BUFFER_SIZE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
EOSQL |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $full_text = ""; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# set up the table |
107
|
0
|
|
|
|
|
|
my $table = Text::FormatTable->new('4l 60l 6l 11l 18l'); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# column headings |
110
|
0
|
|
|
|
|
|
$table->head('', 'Tasks', 'TaskID', 'Importance', 'Requested On'); |
111
|
0
|
|
|
|
|
|
$table->rule('-'); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
while (my $row = Goo::Database::get_result_hash($query)) { |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $index_key = $profile->get_next_index_key(); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$profile->add_option($index_key, "$row->{taskid}.task", "Goo::ThingProfileOption"); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# print "addin conter === $counter \n"; |
120
|
0
|
|
|
|
|
|
$table->row("[$index_key]", $row->{title}, $row->{taskid}, |
121
|
|
|
|
|
|
|
$row->{importance}, $row->{requestedon}); |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$full_text .= $row->{title} . " " . $row->{description}; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return (Goo::Prompter::highlight_options($table->render()), $full_text); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
############################################################################### |
132
|
|
|
|
|
|
|
# |
133
|
|
|
|
|
|
|
# run - show the care-o-meter |
134
|
|
|
|
|
|
|
# |
135
|
|
|
|
|
|
|
############################################################################### |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub run { |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
0
|
1
|
|
my ($this, $thing) = @_; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $profile = Goo::Profile->new(Goo::Loader::load("care.goo")); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# show a profile of the Things I need to care about |
144
|
0
|
|
|
|
|
|
while (1) { |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# profile clear |
147
|
0
|
|
|
|
|
|
$profile->clear(); |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$profile->show_header("CareOMeter", "Things I need to care about", "care.goo"); |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my $full_text; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# add the tasks I care about |
154
|
0
|
|
|
|
|
|
my ($task_table, $task_text) = $this->get_tasks_table($profile); |
155
|
0
|
|
|
|
|
|
$full_text .= $task_text; |
156
|
0
|
|
|
|
|
|
$profile->add_rendered_table($task_table); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# add the bugs I care about |
159
|
0
|
|
|
|
|
|
my ($bugs_table, $bugs_text) = $this->get_bugs_table($profile); |
160
|
0
|
|
|
|
|
|
$full_text .= $bugs_text; |
161
|
0
|
|
|
|
|
|
$profile->add_rendered_table($bugs_table); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# add a list of Things found in this Thing |
164
|
0
|
|
|
|
|
|
$profile->add_things_table($full_text); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# show the profile and all the rendered tables |
167
|
0
|
|
|
|
|
|
$profile->display(); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# prompt the user for the next command |
170
|
0
|
|
|
|
|
|
$profile->get_command(); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
__END__ |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 NAME |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Goo::CareOMeter - Show an ordered list of Things you care about |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 SYNOPSIS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
use Goo::CareOMeter; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 DESCRIPTION |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
The Care[O]Meter is a top-level action handler that shows an ordered list of Things you care about. |
192
|
|
|
|
|
|
|
It helps answer the question, "what do I do next?" |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 METHODS |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item get_bugs_table |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
return a table of bugs I care about ranked by descending care_factor |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item get_tasks_table |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
return a table of tasks I care about ranked by descending care_factor |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item run |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
show the Care-O-Meter |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 SEE ALSO |
217
|
|
|
|
|
|
|
|