Bugzilla – Attachment 94504 Details for
Bug 23673
Separate time sent from time created in message_queue table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23673: Add "Time status changed" column to patron's notices
Bug-23673-Add-Time-status-changed-column-to-patron.patch (text/plain), 6.35 KB, created by
Agustín Moyano
on 2019-10-21 23:29:13 UTC
(
hide
)
Description:
Bug 23673: Add "Time status changed" column to patron's notices
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2019-10-21 23:29:13 UTC
Size:
6.35 KB
patch
obsolete
>From 3fb4d205a5eef8e4043415cd619507e11e879f50 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Mon, 21 Oct 2019 19:18:55 -0300 >Subject: [PATCH] Bug 23673: Add "Time status changed" column to patron's > notices > >This patch adds "Time status changed" column to patron's notices tab. It also adds logic to C4::Letters to update time_status_changed column when status is changed, and leaves time_queued with message creation time. > >To test: > >1. Apply patches. > >2. Restart plack. > >3. Choose a patron and add a purchase suggestion. > >4. Change suggestion status. > >5. Open patron's notifications. >CHECK => Messages table has now "Time status changed" and "Time created" columns, and "Time" column is gone. >SUCCESS => There is a message with status pending, with a "time created" and no "time status changed" > >6. Execute in the shell in Koha directory > > $ ./misc/cronjobs/process_message_queue.pl > >7. Open patron's notifications one more time. >SUCCESS => The message changed status. Time created remained the same, and now "time status changed" has the current timestamp. > >8. Resend the message and repeat sep 6. >SUCCESS => Every time you change the status, time created remains the same and time status changed updates. > >9. prove t/db_dependant/Letters.t > >10. Sign off >--- > C4/Letters.pm | 8 ++++---- > .../intranet-tmpl/prog/en/modules/members/notices.tt | 6 ++++-- > t/db_dependent/Letters.t | 7 ++++++- > 3 files changed, 14 insertions(+), 7 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index bdb213a49e..1e79e276a7 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1070,7 +1070,7 @@ sub GetQueuedMessages { > > my $dbh = C4::Context->dbh(); > my $statement = << 'ENDSQL'; >-SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued >+SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, time_status_changed > FROM message_queue > ENDSQL > >@@ -1124,7 +1124,7 @@ sub GetMessage { > return unless $message_id; > my $dbh = C4::Context->dbh; > return $dbh->selectrow_hashref(q| >- SELECT message_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, content_type >+ SELECT message_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, time_status_changed, to_address, from_address, content_type > FROM message_queue > WHERE message_id = ? > |, {}, $message_id ); >@@ -1368,7 +1368,7 @@ sub _is_duplicate { > WHERE message_transport_type = ? > AND borrowernumber = ? > AND letter_code = ? >- AND CAST(time_queued AS date) = CAST(NOW() AS date) >+ AND CAST(time_status_changed AS date) = CAST(NOW() AS date) > AND status="sent" > AND content = ? > |, {}, $message->{message_transport_type}, $message->{borrowernumber}, $message->{letter_code}, $message->{content} ); >@@ -1419,7 +1419,7 @@ sub _set_message_status { > } > > my $dbh = C4::Context->dbh(); >- my $statement = 'UPDATE message_queue SET status= ? WHERE message_id = ?'; >+ my $statement = 'UPDATE message_queue SET status= ?, time_status_changed = NOW() WHERE message_id = ?'; > my $sth = $dbh->prepare( $statement ); > my $result = $sth->execute( $params->{'status'}, > $params->{'message_id'} ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >index b5e2bebe7b..2bc0c90b1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >@@ -35,7 +35,8 @@ > <th>Notice</th> > <th>Type</th> > <th>Status</th> >- <th>Time</th> >+ <th>Time status changed</th> >+ <th>Time created</th> > </tr> > </thead> > <tbody> >@@ -73,6 +74,7 @@ > </div> > [% END %] > </td> >+ <td><span title="[% QUEUED_MESSAGE.time_status_changed | html %]">[% QUEUED_MESSAGE.time_status_changed | $KohaDates with_hours => 1 %]</span></td> > <td><span title="[% QUEUED_MESSAGE.time_queued | html %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td> > </tr> > [% END %] >@@ -98,7 +100,7 @@ > $(document).ready(function() { > $("#noticestable").dataTable($.extend(true, {}, dataTablesDefaults, { > "aaSorting": [[ 3, "desc" ]], >- "aoColumns": [ null,null,null,{ "sType": "title-string" } ], >+ "aoColumns": [ null,null,null, { "sType": "title-string" } ,{ "sType": "title-string" } ], > "sPaginationType": "full" > })); > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 41f2a05fb8..669b771e62 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 69; >+use Test::More tests => 73; > use Test::MockModule; > use Test::Warn; > >@@ -132,7 +132,10 @@ is( $messages->[0]->{subject}, $my_message->{letter}->{title}, 'EnqueueLetter st > is( $messages->[0]->{content}, $my_message->{letter}->{content}, 'EnqueueLetter stores the content correctly' ); > is( $messages->[0]->{message_transport_type}, $my_message->{message_transport_type}, 'EnqueueLetter stores the message type correctly' ); > is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pending correctly' ); >+isnt( $messages->[0]->{time_queued}, undef, 'Time queued inserted by default in message_queue table' ); >+is( $messages->[0]->{time_status_changed}, undef, 'Time status changed undefined by default in message_queue table' ); > >+my $message_time_queued = $messages->[0]->{time_queued}; > > # SendQueuedMessages > my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' }); >@@ -145,6 +148,8 @@ is( > 'failed', > 'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)' > ); >+isnt($messages->[0]->{time_status_changed}, undef, 'Time status changed set on status change' ); >+is($messages->[0]->{time_queued}, $message_time_queued, 'Time queued remaines inmutable' ); > > # ResendMessage > my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); >-- >2.17.1
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 23673
:
94503
|
94504
|
94954
|
96232
|
96346
|
96347
|
96391
|
96392
|
96451
|
96452
|
96643
|
98090
|
98091
|
98419
|
98420
|
98431
|
98432
|
98433
|
98434
|
98435