Bug 26884 - [Omnibus] Refactor overdue_notices.pl
Summary: [Omnibus] Refactor overdue_notices.pl
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 16063
Blocks:
  Show dependency treegraph
 
Reported: 2020-11-01 08:16 UTC by Mark Hofstetter
Modified: 2023-12-09 13:40 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hofstetter 2020-11-01 08:16:19 UTC
command line script overdue_notices.pl should 

1. moved to a module (see https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16063)

2. refactored/cleaned up

most importantly 
3. made idempotent
this could be achived via a checksum/signature including the "defining" fields for the message ie

borrowernumber
subject
content
metadata
letter_code
message_transport_type
to_address
from_address
reply_address
content_type

so before a message is created a checksum is calculated and a look-up in the database is done whether the message already exists (maybe be ignored via a flag)

so no matter how often or "how/too late" the script is executed, no message is "forgotten"/send multiple times
Comment 1 Katrin Fischer 2020-11-01 11:35:59 UTC
The first part is a duplicate with bug 16063 I think - You could move it there and make this bug about the second part only. 

I am not sure how big of a problem resending notices actually is. At least if you are using -t for triggering the notices using the overdue notice trigger set up and running the script daily. Do you have a use case where it might be an issue?
Comment 2 Mark Hofstetter 2020-11-01 11:53:32 UTC
just judging from my experience i'd say the concept of the triggered notice "feels fragile".

You depend on the fact that script is run exactly once daily, it will mostly work, but won't if anything goes wrong.
Comment 3 Katrin Fischer 2020-11-01 12:15:38 UTC
I think it all might depend a bit on how your overdues and fines process looks like. Not trying to shoot down your idea, just trying to help out here with the bug and interested in learning about others use cases. 

In general separate issues should go on separate bugs and descriptive bug titles are key. You can use the 'depends', 'Blocks' and 'See also' to build dependencies. You can also have an "[Omnibus]" improvements bug that serves as a central access point with the patches on separate bugs linked to it.

In our use case the timing of the overdue notices is quite important, especially since they are supposed to go out on a specific schedule and the same day a fine is added if fines are used. Some careful configuration is required to achieve this.
Comment 4 David Cook 2020-11-01 22:58:02 UTC
Sound like some good improvements, but I agree with Katrin. This bug should have a more descriptive title, and individual changes should be in their own bug reports. This one can be an "OMNIBUS" report if you are concerned with grouping together the different changes.

I would add too that unless you're planning to make these changes, Mark, it's unlikely that anyone else is going to make them. Refactoring usually only happens if it's part of a different change. (For instance, I'm planning to refactor export.pl and its supporting libraries as part of an architectural change which needs to call the code differently.)

But thumbs up for the proposed changes. Most Koha scripts would benefit from being moved into modules, so it's certainly a worthwhile idea.