|
Lines 33-38
Koha::Reports - Koha Report Object set class
Link Here
|
| 33 |
|
33 |
|
| 34 |
=cut |
34 |
=cut |
| 35 |
|
35 |
|
|
|
36 |
=head3 running |
| 37 |
|
| 38 |
Returns a list of reports that are currently running |
| 39 |
|
| 40 |
my @query_ids = Koha::Reports->running({ [ user_id => $user->userid ] }); |
| 41 |
|
| 42 |
=cut |
| 43 |
|
| 44 |
sub running { |
| 45 |
my ( $self, $params ) = @_; |
| 46 |
|
| 47 |
my $user_id = $params->{user_id}; |
| 48 |
my $report_id = $params->{report_id}; |
| 49 |
|
| 50 |
my $dbh = Koha::Database->dbh; |
| 51 |
|
| 52 |
my $query = q{ |
| 53 |
SELECT id, info |
| 54 |
FROM information_schema.processlist |
| 55 |
WHERE command != 'Sleep' |
| 56 |
AND info LIKE '%saved_sql.id%' |
| 57 |
}; |
| 58 |
|
| 59 |
my @ids; |
| 60 |
|
| 61 |
my $sth = $dbh->prepare($query); |
| 62 |
$sth->execute(); |
| 63 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 64 |
if ($user_id) { |
| 65 |
next unless $row->{info} =~ /{ user_id: $user_id }/; |
| 66 |
} |
| 67 |
if ($report_id) { |
| 68 |
next unless $row->{info} =~ /{ saved_sql.id: $report_id }/; |
| 69 |
} |
| 70 |
push @ids, $row->{id}; |
| 71 |
} |
| 72 |
|
| 73 |
return @ids; |
| 74 |
} |
| 75 |
|
| 36 |
=head3 _type |
76 |
=head3 _type |
| 37 |
|
77 |
|
| 38 |
Returns name of corresponding DBIC resultset |
78 |
Returns name of corresponding DBIC resultset |
| 39 |
- |
|
|