Line 0
Link Here
|
0 |
- |
1 |
|
|
|
2 |
#!/usr/bin/perl |
3 |
|
4 |
use Modern::Perl; |
5 |
|
6 |
use Koha::Suggestion; |
7 |
use Koha::AuthorisedValue; |
8 |
|
9 |
use String::Random qw( random_string ); |
10 |
|
11 |
my @status_list = ( 'TEST', 'TEST2', 'ASKED', 'ACCEPTED', 'REJECTED', 'CHECKED', 'ORDERED', 'AVAILABLE' ); |
12 |
my @branches = ( "CPL", "FFL", "FPL", "FRL", "IPT", "LPL", "MPL", "PVL", "RPL", "SPL", "TPL", "UPL" ); |
13 |
my @dates = ( "2025-05-01", "2025-05-02", "2025-05-03", "2025-05-04", "2025-05-05" ); |
14 |
my @opac_reasons = ( 'bestseller', 'damaged', 'cheap' ); |
15 |
|
16 |
my $av1 = Koha::AuthorisedValue->new( |
17 |
{ |
18 |
category => 'SUGGEST_STATUS', |
19 |
authorised_value => 'TEST', |
20 |
lib => 'Test', |
21 |
lib_opac => 'Test', |
22 |
imageurl => '', |
23 |
} |
24 |
)->store(); |
25 |
my $av2 = Koha::AuthorisedValue->new( |
26 |
{ |
27 |
category => 'SUGGEST_STATUS', |
28 |
authorised_value => 'TEST2', |
29 |
lib => 'Another test', |
30 |
lib_opac => 'Another test', |
31 |
imageurl => '', |
32 |
} |
33 |
)->store(); |
34 |
my $av3 = Koha::AuthorisedValue->new( |
35 |
{ |
36 |
category => 'OPAC_SUG', |
37 |
authorised_value => 'cheap', |
38 |
lib => 'This is cheap', |
39 |
lib_opac => 'This is cheap', |
40 |
imageurl => '', |
41 |
} |
42 |
)->store(); |
43 |
|
44 |
foreach my $i ( 1 .. 2000 ) { |
45 |
warn $i . " created\n" if $i % 100 == 0; |
46 |
my $title = random_string("cccccccccc"); |
47 |
|
48 |
my $status_index = rand(8); |
49 |
my $branch_index = rand(12); |
50 |
my $dates_index = rand(5); |
51 |
my $opac_index = rand(3); |
52 |
my $patron_id = rand(50) + 1; |
53 |
my $suggestion = Koha::Suggestion->new( |
54 |
{ |
55 |
suggestedby => $patron_id, STATUS => $status_list[$status_index], |
56 |
branchcode => $branches[$branch_index], managedby => 51, itemtype => 'BOOK', |
57 |
suggesteddate => $dates[$dates_index], |
58 |
archived => 0, title => $title, patronreason => $opac_reasons[$opac_index] |
59 |
} |
60 |
)->store; |
61 |
} |
62 |
|
63 |
warn "Complete"; |