|
Lines 2-8
Link Here
|
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
|
4 |
|
| 5 |
use Test::More tests => 16; |
5 |
use Test::More tests => 22; |
| 6 |
use URI::Escape; |
6 |
use URI::Escape; |
| 7 |
|
7 |
|
| 8 |
use C4::Context; |
8 |
use C4::Context; |
|
Lines 127-135
$all = C4::Search::History::get({userid => $userid});
Link Here
|
| 127 |
is( scalar(@$all), 9, 'There are still 9 searches after calling delete without userid' ); |
127 |
is( scalar(@$all), 9, 'There are still 9 searches after calling delete without userid' ); |
| 128 |
delete_all( $userid ); |
128 |
delete_all( $userid ); |
| 129 |
|
129 |
|
|
|
130 |
# Test delete with interval |
| 131 |
add( $userid, $current_sessionid, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ); |
| 132 |
C4::Search::History::delete({ |
| 133 |
userid => $userid, |
| 134 |
interval => 10, |
| 135 |
}); |
| 136 |
$all = C4::Search::History::get({userid => $userid}); |
| 137 |
is( scalar(@$all), 9, 'There are still 9 searches after calling delete with an interval = 10 days' ); |
| 138 |
C4::Search::History::delete({ |
| 139 |
userid => $userid, |
| 140 |
interval => 6, |
| 141 |
}); |
| 142 |
$all = C4::Search::History::get({userid => $userid}); |
| 143 |
is( scalar(@$all), 8, 'There are still 8 searches after calling delete with an interval = 6 days' ); |
| 144 |
C4::Search::History::delete({ |
| 145 |
userid => $userid, |
| 146 |
interval => 2, |
| 147 |
}); |
| 148 |
$all = C4::Search::History::get({userid => $userid}); |
| 149 |
is( scalar(@$all), 2, 'There are still 2 searches after calling delete with an interval = 2 days' ); |
| 150 |
delete_all( $userid ); |
| 151 |
|
| 152 |
add( $userid, $current_sessionid, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ); |
| 153 |
C4::Search::History::delete({ |
| 154 |
userid => $userid, |
| 155 |
interval => 5, |
| 156 |
type => 'biblio', |
| 157 |
}); |
| 158 |
$all = C4::Search::History::get({userid => $userid}); |
| 159 |
is( scalar(@$all), 8, 'There are still 9 searches after calling delete with an interval = 5 days for biblio' ); |
| 160 |
C4::Search::History::delete({ |
| 161 |
userid => $userid, |
| 162 |
interval => 5, |
| 163 |
type => 'authority', |
| 164 |
}); |
| 165 |
$all = C4::Search::History::get({userid => $userid}); |
| 166 |
is( scalar(@$all), 6, 'There are still 6 searches after calling delete with an interval = 5 days for authority' ); |
| 167 |
C4::Search::History::delete({ |
| 168 |
userid => $userid, |
| 169 |
interval => -1, |
| 170 |
}); |
| 171 |
$all = C4::Search::History::get({userid => $userid}); |
| 172 |
is( scalar(@$all), 0, 'There is no search after calling delete with an interval = -1 days' ); |
| 173 |
delete_all( $userid ); |
| 174 |
|
| 130 |
sub add { |
175 |
sub add { |
| 131 |
my ( $userid, $current_session_id, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ) = @_; |
176 |
my ( $userid, $current_session_id, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ) = @_; |
| 132 |
|
177 |
|
|
|
178 |
my $days_ago_2 = dt_from_string()->add_duration( DateTime::Duration->new( days => -2 ) ); |
| 179 |
my $days_ago_4 = dt_from_string()->add_duration( DateTime::Duration->new( days => -4 ) ); |
| 180 |
my $days_ago_6 = dt_from_string()->add_duration( DateTime::Duration->new( days => -6 ) ); |
| 181 |
my $days_ago_8 = dt_from_string()->add_duration( DateTime::Duration->new( days => -8 ) ); |
| 182 |
|
| 133 |
my $query_desc_b1_p = q{first previous biblio search}; |
183 |
my $query_desc_b1_p = q{first previous biblio search}; |
| 134 |
my $first_previous_biblio_search = { |
184 |
my $first_previous_biblio_search = { |
| 135 |
userid => $userid, |
185 |
userid => $userid, |
|
Lines 138-143
sub add {
Link Here
|
| 138 |
query_cgi => $query_cgi_b, |
188 |
query_cgi => $query_cgi_b, |
| 139 |
total => $total, |
189 |
total => $total, |
| 140 |
type => 'biblio', |
190 |
type => 'biblio', |
|
|
191 |
time => $days_ago_2, |
| 141 |
}; |
192 |
}; |
| 142 |
|
193 |
|
| 143 |
my $query_desc_a1_p = q{first previous authority search}; |
194 |
my $query_desc_a1_p = q{first previous authority search}; |
|
Lines 148-153
sub add {
Link Here
|
| 148 |
query_cgi => $query_cgi_a, |
199 |
query_cgi => $query_cgi_a, |
| 149 |
total => $total, |
200 |
total => $total, |
| 150 |
type => 'authority', |
201 |
type => 'authority', |
|
|
202 |
time => $days_ago_2, |
| 151 |
}; |
203 |
}; |
| 152 |
|
204 |
|
| 153 |
my $query_desc_b2_p = q{second previous biblio search}; |
205 |
my $query_desc_b2_p = q{second previous biblio search}; |
|
Lines 158-163
sub add {
Link Here
|
| 158 |
query_cgi => $query_cgi_b, |
210 |
query_cgi => $query_cgi_b, |
| 159 |
total => $total, |
211 |
total => $total, |
| 160 |
type => 'biblio', |
212 |
type => 'biblio', |
|
|
213 |
time => $days_ago_4, |
| 161 |
}; |
214 |
}; |
| 162 |
|
215 |
|
| 163 |
my $query_desc_a2_p = q{second previous authority search}; |
216 |
my $query_desc_a2_p = q{second previous authority search}; |
|
Lines 168-173
sub add {
Link Here
|
| 168 |
query_cgi => $query_cgi_a, |
221 |
query_cgi => $query_cgi_a, |
| 169 |
total => $total, |
222 |
total => $total, |
| 170 |
type => 'authority', |
223 |
type => 'authority', |
|
|
224 |
time => $days_ago_4, |
| 171 |
}; |
225 |
}; |
| 172 |
|
226 |
|
| 173 |
|
227 |
|
|
Lines 180-185
sub add {
Link Here
|
| 180 |
query_cgi => $query_cgi_b, |
234 |
query_cgi => $query_cgi_b, |
| 181 |
total => $total, |
235 |
total => $total, |
| 182 |
type => 'biblio', |
236 |
type => 'biblio', |
|
|
237 |
time => $days_ago_4, |
| 183 |
}; |
238 |
}; |
| 184 |
|
239 |
|
| 185 |
my $query_desc_a1_c = q{first current authority search}; |
240 |
my $query_desc_a1_c = q{first current authority search}; |
|
Lines 190-195
sub add {
Link Here
|
| 190 |
query_cgi => $query_cgi_a, |
245 |
query_cgi => $query_cgi_a, |
| 191 |
total => $total, |
246 |
total => $total, |
| 192 |
type => 'authority', |
247 |
type => 'authority', |
|
|
248 |
time => $days_ago_4, |
| 193 |
}; |
249 |
}; |
| 194 |
|
250 |
|
| 195 |
my $query_desc_b2_c = q{second current biblio search}; |
251 |
my $query_desc_b2_c = q{second current biblio search}; |
|
Lines 200-205
sub add {
Link Here
|
| 200 |
query_cgi => $query_cgi_b, |
256 |
query_cgi => $query_cgi_b, |
| 201 |
total => $total, |
257 |
total => $total, |
| 202 |
type => 'biblio', |
258 |
type => 'biblio', |
|
|
259 |
time => $days_ago_6, |
| 203 |
}; |
260 |
}; |
| 204 |
|
261 |
|
| 205 |
my $query_desc_a2_c = q{second current authority search}; |
262 |
my $query_desc_a2_c = q{second current authority search}; |
|
Lines 210-215
sub add {
Link Here
|
| 210 |
query_cgi => $query_cgi_a, |
267 |
query_cgi => $query_cgi_a, |
| 211 |
total => $total, |
268 |
total => $total, |
| 212 |
type => 'authority', |
269 |
type => 'authority', |
|
|
270 |
time => $days_ago_6, |
| 213 |
}; |
271 |
}; |
| 214 |
|
272 |
|
| 215 |
my $query_desc_a3_c = q{third current authority search}; |
273 |
my $query_desc_a3_c = q{third current authority search}; |
|
Lines 220-225
sub add {
Link Here
|
| 220 |
query_cgi => $query_cgi_a, |
278 |
query_cgi => $query_cgi_a, |
| 221 |
total => $total, |
279 |
total => $total, |
| 222 |
type => 'authority', |
280 |
type => 'authority', |
|
|
281 |
time => $days_ago_8, |
| 223 |
}; |
282 |
}; |
| 224 |
|
283 |
|
| 225 |
|
284 |
|