Bug 33901 - Only one issue shown when testing prediction pattern
Summary: Only one issue shown when testing prediction pattern
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Serials (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 30718
Blocks:
  Show dependency treegraph
 
Reported: 2023-06-05 16:08 UTC by Caroline Cyr La Rose
Modified: 2023-12-28 20:46 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:
23.11.00,23.05.02,22.11.08


Attachments
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today (1.88 KB, patch)
2023-06-07 09:52 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today (1.95 KB, patch)
2023-06-07 13:05 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today (2.00 KB, patch)
2023-06-08 20:40 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Caroline Cyr La Rose 2023-06-05 16:08:30 UTC
I think this is similar to bug 32554, but in another page/context.

When creating a numbering pattern, you have the option to test it before saving it. However, it doesn't show the number of issues you select in the test.

To recreate:
1. Go to Serials > Manage numbering patterns
2. Click Edit next to one of the existing patterns (e.g. Number)
3. Enter information in the Test prediction pattern section
   -  Frequency: choose one (e.g. 1/month)
   -  First issue publication date: enter a date (e.g. 2023-06-01)
   -  Subscription length: issues + enter a number of issues (e.g. 12)
   -  Locale: leave empty
   -  Begins with: enter a number in the X column, e.g. 42
4. Click Test pattern

--> Only one issue is shown, no matter how many you enter in Subscription length.

Having only one issue doesn't help at all to know if your numbering pattern will work correctly.
Comment 1 Jonathan Druart 2023-06-07 09:50:29 UTC
This was wrong:

-$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
+$enddate = dt_from_string($enddate)->ymd;
Comment 2 Jonathan Druart 2023-06-07 09:52:37 UTC
Created attachment 152084 [details] [review]
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today

If the end date is not set we should not set it to today.
On bug 30718 the following change was wrong:
-$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
+$enddate = dt_from_string($enddate)->ymd;

output_pref returns undef if str is empty
After the change we returned today's date.

Test plan:
1. Go to Serials > Manage numbering patterns
2. Click Edit next to one of the existing patterns (e.g. Number)
3. Enter information in the Test prediction pattern section
   -  Frequency: choose one (e.g. 1/month)
   -  First issue publication date: enter a date (e.g. 2023-06-01)
   -  Subscription length: issues + enter a number of issues (e.g. 12)
   -  Locale: leave empty
   -  Begins with: enter a number in the X column, e.g. 42
4. Click Test pattern
=> Without this patch only one issue is shown, no matter how many you enter in Subscription length
=> With this patch applied the end date is not set to today and the
prediction pattern list is correct
Comment 3 Caroline Cyr La Rose 2023-06-07 13:05:14 UTC
Created attachment 152105 [details] [review]
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today

If the end date is not set we should not set it to today.
On bug 30718 the following change was wrong:
-$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
+$enddate = dt_from_string($enddate)->ymd;

output_pref returns undef if str is empty
After the change we returned today's date.

Test plan:
1. Go to Serials > Manage numbering patterns
2. Click Edit next to one of the existing patterns (e.g. Number)
3. Enter information in the Test prediction pattern section
   -  Frequency: choose one (e.g. 1/month)
   -  First issue publication date: enter a date (e.g. 2023-06-01)
   -  Subscription length: issues + enter a number of issues (e.g. 12)
   -  Locale: leave empty
   -  Begins with: enter a number in the X column, e.g. 42
4. Click Test pattern
=> Without this patch only one issue is shown, no matter how many you enter in Subscription length
=> With this patch applied the end date is not set to today and the
prediction pattern list is correct

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 4 Caroline Cyr La Rose 2023-06-07 13:05:36 UTC
Thanks Jonathan! It's much better now
Comment 5 Caroline Cyr La Rose 2023-06-07 13:08:30 UTC
I think this patch may also solve bug 32554
Comment 6 Katrin Fischer 2023-06-08 20:40:53 UTC
Created attachment 152217 [details] [review]
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today

If the end date is not set we should not set it to today.
On bug 30718 the following change was wrong:
-$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
+$enddate = dt_from_string($enddate)->ymd;

output_pref returns undef if str is empty
After the change we returned today's date.

Test plan:
1. Go to Serials > Manage numbering patterns
2. Click Edit next to one of the existing patterns (e.g. Number)
3. Enter information in the Test prediction pattern section
   -  Frequency: choose one (e.g. 1/month)
   -  First issue publication date: enter a date (e.g. 2023-06-01)
   -  Subscription length: issues + enter a number of issues (e.g. 12)
   -  Locale: leave empty
   -  Begins with: enter a number in the X column, e.g. 42
4. Click Test pattern
=> Without this patch only one issue is shown, no matter how many you enter in Subscription length
=> With this patch applied the end date is not set to today and the
prediction pattern list is correct

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Katrin Fischer 2023-06-08 20:41:14 UTC
Much better, thx Caroline for filing and Jonathan for the fix :)
Comment 8 Tomás Cohen Arazi 2023-06-09 11:42:57 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 9 Martin Renvoize 2023-07-12 08:24:29 UTC
Thanks for all the hard work!

Pushed to 23.05.x for the next release
Comment 10 Matt Blenkinsop 2023-07-12 09:36:26 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x
Comment 11 Sue 2023-07-26 19:10:24 UTC
Still experiencing only one issue showing when testing prediction patterns in 22.11.07.  Similar to bug 32554
Comment 12 Katrin Fischer 2023-07-26 19:31:41 UTC
(In reply to Sue from comment #11)
> Still experiencing only one issue showing when testing prediction patterns
> in 22.11.07.  Similar to bug 32554

This is to be expected: see the Versions released in at the top. The fix will be included in 22.11.08.