line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package News::Pan::Server::Group::_Search; |
2
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
91
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
102
|
|
4
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
215
|
|
5
|
3
|
|
|
3
|
|
16
|
use LEOCHARRE::DEBUG; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
20
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _search_set_subjects_matching { |
13
|
8
|
|
|
8
|
|
13
|
my ($self,$arg) = @_; |
14
|
8
|
50
|
|
|
|
18
|
defined $arg or confess('missing arg'); |
15
|
8
|
50
|
|
|
|
19
|
ref $arg eq 'ARRAY' or confess('not array ref'); |
16
|
8
|
|
|
|
|
14
|
$self->{_data_}->{search_subjects_matching} = $arg; |
17
|
8
|
|
|
|
|
16
|
return 1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _search_subjects_matching { |
21
|
32
|
|
|
32
|
|
39
|
my $self = shift; |
22
|
32
|
100
|
|
|
|
80
|
unless (defined $self->{_data_}->{search_subjects_matching}){ |
23
|
2
|
|
|
|
|
17
|
$self->{_data_}->{search_subjects_matching} = $self->subjects; |
24
|
|
|
|
|
|
|
} |
25
|
32
|
|
|
|
|
74
|
return $self->{_data_}->{search_subjects_matching}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _search_filter { |
32
|
8
|
|
|
8
|
|
15
|
my ($self,$term,$case_sensitive,$negative) = @_; |
33
|
8
|
50
|
|
|
|
20
|
defined $term or confess('missing arg'); |
34
|
8
|
|
50
|
|
|
30
|
$case_sensitive ||= 0; |
35
|
8
|
|
100
|
|
|
24
|
$negative ||=0; |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
18
|
debug(sprintf "count before %s, ", $self->search_count ); |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
51
|
my @filtered; |
40
|
|
|
|
|
|
|
|
41
|
8
|
50
|
33
|
|
|
36
|
if ($case_sensitive and $negative){ |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
@filtered = grep { !/$term/ } @{$self->_search_subjects_matching}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
43
|
0
|
|
|
|
|
0
|
debug("[$term] case sensitive and negative, "); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
elsif ($case_sensitive){ |
47
|
0
|
|
|
|
|
0
|
@filtered = grep { /$term/ } @{$self->_search_subjects_matching}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
48
|
0
|
|
|
|
|
0
|
debug("[$term] case sensitive, "); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
elsif ($negative){ |
52
|
4
|
|
|
|
|
5
|
@filtered = grep { !/$term/ } @{$self->_search_subjects_matching}; |
|
18
|
|
|
|
|
78
|
|
|
4
|
|
|
|
|
9
|
|
53
|
4
|
|
|
|
|
14
|
debug("[$term] negative, "); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
else { |
57
|
4
|
|
|
|
|
7
|
@filtered = grep { /$term/i } @{$self->_search_subjects_matching}; |
|
19
|
|
|
|
|
114
|
|
|
4
|
|
|
|
|
9
|
|
58
|
4
|
|
|
|
|
15
|
debug("[$term] positive match, "); |
59
|
|
|
|
|
|
|
} |
60
|
8
|
|
|
|
|
70
|
$self->_search_set_subjects_matching(\@filtered); |
61
|
|
|
|
|
|
|
|
62
|
8
|
50
|
|
|
|
25
|
if (DEBUG){ |
63
|
0
|
|
|
|
|
0
|
for (@filtered){ |
64
|
0
|
|
|
|
|
0
|
print STDERR " -ok: $_ \n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
78
|
debug(sprintf "count after %s\n\n", $self->search_count ); |
69
|
|
|
|
|
|
|
|
70
|
8
|
|
|
|
|
67
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _search_subjects_matching_count { |
75
|
23
|
|
|
23
|
|
27
|
my $self = shift; |
76
|
23
|
|
|
|
|
27
|
my $count = scalar @{$self->_search_subjects_matching}; |
|
23
|
|
|
|
|
52
|
|
77
|
23
|
|
|
|
|
126
|
return $count; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub search_add { |
84
|
1
|
|
|
1
|
1
|
68
|
my ($self,$string) = @_; |
85
|
1
|
50
|
|
|
|
4
|
defined $string or confess('missing arg'); |
86
|
1
|
50
|
0
|
|
|
6
|
$string=~/\w/ or warn("will not filter, no word chars") and return; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
6
|
$string=~/^\s|\s$/g; |
89
|
1
|
|
|
|
|
7
|
my @terms = split(/\W/,$string); |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
2
|
for (@terms){ |
92
|
4
|
|
|
|
|
20
|
$self->_search_filter($_); |
93
|
|
|
|
|
|
|
} |
94
|
1
|
|
|
|
|
6
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub search_add_exact { |
98
|
0
|
|
|
0
|
1
|
0
|
my ($self,$string) = @_; |
99
|
0
|
0
|
|
|
|
0
|
defined $string or confess('missing arg'); |
100
|
0
|
|
|
|
|
0
|
$self->_search_filter($string,1); |
101
|
0
|
|
|
|
|
0
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub search_negative { |
107
|
1
|
|
|
1
|
1
|
3
|
my ($self,$string) = @_; |
108
|
1
|
50
|
|
|
|
4
|
defined $string or confess('missing arg'); |
109
|
1
|
50
|
0
|
|
|
8
|
$string=~/\w/ or warn("will not filter, no word chars") and return; |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
17
|
$string=~/^\s|\s$/g; |
112
|
1
|
|
|
|
|
6
|
my @terms = split(/\W/,$string); |
113
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
3
|
for (@terms){ |
115
|
4
|
|
|
|
|
14
|
$self->_search_filter($_,0,1); |
116
|
|
|
|
|
|
|
} |
117
|
1
|
|
|
|
|
6
|
return 1; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub search_negative_exact { |
121
|
0
|
|
|
0
|
1
|
0
|
my ($self,$string) = @_; |
122
|
0
|
0
|
|
|
|
0
|
defined $string or confess('missing arg'); |
123
|
0
|
|
|
|
|
0
|
$self->_search_filter($string,1,1); |
124
|
0
|
|
|
|
|
0
|
return 1; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub search_count { |
128
|
23
|
|
|
23
|
1
|
79
|
my $self = shift; |
129
|
23
|
|
|
|
|
84
|
return $self->_search_subjects_matching_count; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub search_results { |
133
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
134
|
1
|
|
|
|
|
3
|
return $self->_search_subjects_matching; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub search_reset { |
138
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
139
|
1
|
|
|
|
|
2
|
$self->{_data_}->{search_subjects_matching} = undef; |
140
|
1
|
|
|
|
|
8
|
return 1; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__ |