App/Chart/Gtk2/Symlist/Alerts.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 63 CC 1 SCAR 6.9
CC
1
Cov
0%
name
2.0
instance
2.0
interested_symbols
2.0
CRAP 2.0
1 # Copyright 2007, 2008, 2009, 2011 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3, or (at your option) any later version.
8 #
9 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Chart. If not, see <http://www.gnu.org/licenses/>.
16  
17 package App::Chart::Gtk2::Symlist::Alerts;
18 use strict;
19 use warnings;
20 use Locale::TextDomain ('App-Chart');
21  
22 use App::Chart;
23  
24 use App::Chart::Gtk2::Symlist::Alphabetical;
25 use Glib::Object::Subclass
26 'App::Chart::Gtk2::Symlist::Alphabetical';
27  
28 sub name { return __('Alerts') }
29  
30 sub instance {
31 my ($class) = @_;
32 return $class->new_from_key ('alerts');
33 }
34  
35 sub interested_symbols {
36 my ($self) = @_;
37 ref $self or $self = $self->instance;
38  
39 # all current alerts list contents
40 my @symbols = $self->symbols;
41  
42 # anything with an alert level and in the all list (so exclude historical
43 # symbols, and symbols deleted from the database but user notes remaining)
44 require App::Chart::DBI;
45 my $dbh = App::Chart::DBI->instance;
46 my $aref = $dbh->selectcol_arrayref ('SELECT symbol FROM alert');
47 require App::Chart::Gtk2::Symlist::All;
48 my $all_hash = App::Chart::Gtk2::Symlist::All->instance->hash;
49 push @symbols, grep {exists $all_hash->{$_}} @$aref;
50  
51 require List::MoreUtils;
52 @symbols = List::MoreUtils::uniq (@symbols);
53  
54 @symbols = sort { App::Chart::symbol_cmp($a,$b) } @symbols;
55 return @symbols;
56 }
57  
58 1;
59 __END__