Bug 23673: Add "Updated on" column to patron's notices

This patch adds "Updated on" column to patron's notices tab. It also adds logic to C4::Letters to retrieve updated_on column.

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 "Updated on" and "Time created" columns, and "Time" column is gone.
   SUCCESS => There is a message with status pending, with a "time created" that equals "updated on"
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 "updated on" 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 updated on updates.
9. Run `prove t/db_dependant/Letters.t`
10. Sign off

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Agustin Moyano 2019-10-21 19:18:55 -03:00 committed by Martin Renvoize
parent 76c0a06728
commit 5ac7f3690d
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
3 changed files with 14 additions and 6 deletions

View file

@ -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, updated_on
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, updated_on, 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(updated_on AS date) = CAST(NOW() AS date)
AND status="sent"
AND content = ?
|, {}, $message->{message_transport_type}, $message->{borrowernumber}, $message->{letter_code}, $message->{content} );

View file

@ -35,7 +35,8 @@
<th>Notice</th>
<th>Type</th>
<th>Status</th>
<th>Time</th>
<th>Updated on</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.updated_on | $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"
}));

View file

@ -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,8 +132,12 @@ 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]->{updated_on}, $messages->[0]->{time_queued}, 'Time status changed equals time queued when created in message_queue table' );
my $message_time_queued = $messages->[0]->{time_queued};
sleep 1;
# SendQueuedMessages
my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' });
is($messages_processed, 0, 'No queued messages processed if type limit passed with unused type');
@ -145,6 +149,8 @@ is(
'failed',
'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
);
isnt($messages->[0]->{updated_on}, $messages->[0]->{time_queued}, 'Time status changed differs from time queued when status changes' );
is($messages->[0]->{time_queued}, $message_time_queued, 'Time queued remaines inmutable' );
# ResendMessage
my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id});