Bugzilla – Attachment 193918 Details for
Bug 41918
Prevent users from running the same report multiple times concurrently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41918: Add method to see running report queries by user and id
516e7ec.patch (text/plain), 2.05 KB, created by
Kyle M Hall (khall)
on 2026-02-25 16:42:31 UTC
(
hide
)
Description:
Bug 41918: Add method to see running report queries by user and id
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2026-02-25 16:42:31 UTC
Size:
2.05 KB
patch
obsolete
>From 516e7ec0f691fd7c6b717abb28a3672d7c7cdb89 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 25 Feb 2026 10:08:15 -0500 >Subject: [PATCH] Bug 41918: Add method to see running report queries by user > and id > >--- > Koha/Report.pm | 5 ++++- > Koha/Reports.pm | 40 ++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+), 1 deletion(-) > >diff --git a/Koha/Report.pm b/Koha/Report.pm >index b6a210eb9fc..c092fe06fef 100644 >--- a/Koha/Report.pm >+++ b/Koha/Report.pm >@@ -231,7 +231,10 @@ sub prep_report { > > $sql = $self->_might_add_limit($sql) if $params->{export}; > >- $sql = "$sql /* saved_sql.id: ${\( $self->id )} */"; >+ my $report_id = $self->id; >+ my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : 0; >+ $sql .= " /* { saved_sql.id: $report_id } { user_id: $user_id } */"; >+ > return $sql, $headers; > } > >diff --git a/Koha/Reports.pm b/Koha/Reports.pm >index a1e246c5800..7ee5ccc19ec 100644 >--- a/Koha/Reports.pm >+++ b/Koha/Reports.pm >@@ -33,6 +33,46 @@ Koha::Reports - Koha Report Object set class > > =cut > >+=head3 running >+ >+Returns a list of reports that are currently running >+ >+my @query_ids = Koha::Reports->running({ [ user_id => $user->userid ] }); >+ >+=cut >+ >+sub running { >+ my ( $self, $params ) = @_; >+ >+ my $user_id = $params->{user_id}; >+ my $report_id = $params->{report_id}; >+ >+ my $dbh = Koha::Database->dbh; >+ >+ my $query = q{ >+ SELECT id, info >+ FROM information_schema.processlist >+ WHERE command != 'Sleep' >+ AND info LIKE '%saved_sql.id%' >+ }; >+ >+ my @ids; >+ >+ my $sth = $dbh->prepare($query); >+ $sth->execute(); >+ while ( my $row = $sth->fetchrow_hashref ) { >+ if ($user_id) { >+ next unless $row->{info} =~ /{ user_id: $user_id }/; >+ } >+ if ($report_id) { >+ next unless $row->{info} =~ /{ saved_sql.id: $report_id }/; >+ } >+ push @ids, $row->{id}; >+ } >+ >+ return @ids; >+} >+ > =head3 _type > > Returns name of corresponding DBIC resultset >-- >2.50.1 (Apple Git-155) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41918
: 193918 |
193919
|
193920