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

(-)a/Koha/Report.pm (-1 / +4 lines)
Lines 231-237 sub prep_report { Link Here
231
231
232
    $sql = $self->_might_add_limit($sql) if $params->{export};
232
    $sql = $self->_might_add_limit($sql) if $params->{export};
233
233
234
    $sql = "$sql /* saved_sql.id: ${\( $self->id )} */";
234
    my $report_id = $self->id;
235
    my $user_id   = C4::Context->userenv ? C4::Context->userenv->{number} : 0;
236
    $sql .= " /* { saved_sql.id: $report_id } { user_id: $user_id } */";
237
235
    return $sql, $headers;
238
    return $sql, $headers;
236
}
239
}
237
240
(-)a/Koha/Reports.pm (-1 / +40 lines)
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
- 

Return to bug 41918