View | Details | Raw Unified | Return to bug 17323
Collapse All | Expand All

(-)a/C4/Search/History.pm (-3 / +3 lines)
Lines 25-38 sub add { Link Here
25
    # Add the request the user just made
25
    # Add the request the user just made
26
    my $query = q{
26
    my $query = q{
27
        INSERT INTO search_history(
27
        INSERT INTO search_history(
28
            userid, sessionid, query_desc, query_cgi, type, total, time
28
            userid, sessionid, query_desc, query_cgi, type, total} . ( $time ? ', time' : '' ) . q{
29
        ) VALUES(
29
        ) VALUES(
30
            ?, ?, ?, ?, ?, ?, ?
30
            ?, ?, ?, ?, ?, ?} . ( $time ? ', ?' : '' ) . q{
31
        )
31
        )
32
    };
32
    };
33
    my $sth = $dbh->prepare($query);
33
    my $sth = $dbh->prepare($query);
34
    $sth->execute( $userid, $sessionid, $query_desc, $query_cgi, $type,
34
    $sth->execute( $userid, $sessionid, $query_desc, $query_cgi, $type,
35
        $total, $time );
35
        $total, ( $time ? $time : () ) );
36
}
36
}
37
37
38
sub add_to_session {
38
sub add_to_session {
(-)a/t/db_dependent/Search/History.t (-2 / +17 lines)
Lines 2-13 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 25;
5
use Test::More tests => 26;
6
use Test::Warn;
6
use Test::Warn;
7
use URI::Escape;
7
use URI::Escape;
8
use List::Util qw( shuffle );
8
use List::Util qw( shuffle );
9
9
10
use C4::Context;
10
use C4::Context;
11
use Koha::DateUtils;
11
my $dbh = C4::Context->dbh;
12
my $dbh = C4::Context->dbh;
12
$dbh->{AutoCommit} = 0;
13
$dbh->{AutoCommit} = 0;
13
$dbh->{RaiseError} = 1;
14
$dbh->{RaiseError} = 1;
Lines 197-202 C4::Search::History::delete({ Link Here
197
$all = C4::Search::History::get({userid => $userid});
198
$all = C4::Search::History::get({userid => $userid});
198
is( scalar(@$all), 0, 'There is no search after calling delete with an interval = -1 days' );
199
is( scalar(@$all), 0, 'There is no search after calling delete with an interval = -1 days' );
199
200
201
# If time is null, it must be set to NOW()
202
my $query_desc_b1_p = q{first previous biblio search};
203
C4::Search::History::add( {
204
    userid => $userid,
205
    sessionid => $previous_sessionid,
206
    query_desc => $query_desc_b1_p,
207
    query_cgi => $query_cgi_b,
208
    total => $total,
209
    type => 'biblio',
210
});
211
my $search_history_id = $dbh->last_insert_id( undef, undef, 'search_history', undef );
212
my $search_history = C4::Search::History::get({ id => $search_history_id });
213
is( output_pref({ dt => dt_from_string($search_history->[0]->{time}), dateonly => 1 }), output_pref({ dt => dt_from_string, dateonly => 1 }), "Inserting a new search history should handle undefined time" );
214
215
200
delete_all( $userid );
216
delete_all( $userid );
201
217
202
sub add {
218
sub add {
203
- 

Return to bug 17323