Bug 12671 - Guess next serial date when there are several issues per unit
Summary: Guess next serial date when there are several issues per unit
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Serials (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 16116
  Show dependency treegraph
 
Reported: 2014-07-29 14:43 UTC by Julian Maurice
Modified: 2017-06-14 22:11 UTC (History)
5 users (show)

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


Attachments
Bug 12671: Refactor GetNextDate (9.56 KB, patch)
2014-07-29 14:44 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 12671: Guess next serial date when there are several issues per unit (20.29 KB, patch)
2014-07-29 14:44 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts. (3.34 KB, patch)
2014-12-23 07:56 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 12671: Refactor GetNextDate (9.68 KB, patch)
2014-12-23 09:12 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 12671: Guess next serial date when there are several issues per unit (20.84 KB, patch)
2014-12-23 09:18 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 12671: Refactor GetNextDate (9.68 KB, patch)
2015-03-16 11:03 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 12671: Guess next serial date when there are several issues per unit (20.83 KB, patch)
2015-03-16 11:04 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts. (3.33 KB, patch)
2015-03-16 11:04 UTC, Julian Maurice
Details | Diff | Splinter Review
[PASSED QA] Bug 12671: Refactor GetNextDate (9.75 KB, patch)
2015-03-27 18:37 UTC, Kyle M Hall
Details | Diff | Splinter Review
[PASSED QA] Bug 12671: Guess next serial date when there are several issues per unit (20.90 KB, patch)
2015-03-27 18:37 UTC, Kyle M Hall
Details | Diff | Splinter Review
[PASSED QA] Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts. (3.41 KB, patch)
2015-03-27 18:37 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2014-07-29 14:43:42 UTC

    
Comment 1 Julian Maurice 2014-07-29 14:44:43 UTC Comment hidden (obsolete)
Comment 2 Julian Maurice 2014-07-29 14:44:46 UTC Comment hidden (obsolete)
Comment 3 Olli-Antti Kivilahti 2014-12-23 07:56:44 UTC Comment hidden (obsolete)
Comment 4 Olli-Antti Kivilahti 2014-12-23 07:57:51 UTC
Thanks for the awesome patch!
I am pushing this to production and getting feedback from our Serials people.
We are just inserting our subscriptions using the Koha's serials-module.
Comment 5 Olli-Antti Kivilahti 2014-12-23 09:12:15 UTC Comment hidden (obsolete)
Comment 6 Olli-Antti Kivilahti 2014-12-23 09:18:32 UTC Comment hidden (obsolete)
Comment 7 Julian Maurice 2015-02-12 09:06:48 UTC
Changed status to signed off
Comment 8 Katrin Fischer 2015-03-16 01:07:41 UTC
I am sorry, patches no longer apply on current master:

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts.
fatal: sha1 information is lacking or useless (C4/Serials.pm).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts.
The copy of the patch that failed is found in:
   /home/katrin/kohaclone/.git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-12671-Guess-next-serial-date-when-there-are-se-UWVsuV.patch
Comment 9 Julian Maurice 2015-03-16 11:03:43 UTC Comment hidden (obsolete)
Comment 10 Julian Maurice 2015-03-16 11:04:09 UTC Comment hidden (obsolete)
Comment 11 Julian Maurice 2015-03-16 11:04:23 UTC Comment hidden (obsolete)
Comment 12 Julian Maurice 2015-03-16 11:05:48 UTC
Patches applied well on master, but were in the wrong order.
Anyway, patches rebased and reordered.
Comment 13 Olli-Antti Kivilahti 2015-03-16 11:07:14 UTC
This works well in production for 4 months already. Somebody should push this to master asap!
Comment 14 Kyle M Hall 2015-03-27 18:37:11 UTC
Created attachment 37340 [details] [review]
[PASSED QA] Bug 12671: Refactor GetNextDate

A much needed refactoring. Thanks for seeing the effort through.
Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Kyle M Hall 2015-03-27 18:37:26 UTC
Created attachment 37341 [details] [review]
[PASSED QA] Bug 12671: Guess next serial date when there are several issues per unit

This guess uses the following algorithm
1/ Get the number of days remaining from first issue of this unit of
time until the end of the unit of time (using 7 days for week, 28 for
month and 365 for year)
2/ Divide it by the number of issues per unit
3/ Take the integer part of the result, this is the number of days to
add to previous serial published date

This patch also try to guess the date of the first issue of a unit of
time. Before that, it was:
- for week: monday of week
- for month: 1st day of month
- for year: 1st day of year
Now it uses firstacquidate.

Example:
  firstacquidate = 1970-01-07 (wednesday)
  unit = week
  issuesperunit = 2 (2 issues per week)

  From wednesday to sunday, there are 4 days so we add 2 days to get the
  next date.
  The next dates should be:
  - 1970-01-09 (+ 2 days)
  - 1970-01-14 (wednesday of next week)
  - 1970-01-16 (+ 2 days)
  - ... and so on

Test plan:
1/ Go to numbering pattern creation page (Serials -> Manager numbering
patterns -> New numbering pattern)
2/ In "Test prediction pattern" fieldset, set subscription length to 50
issues (this avoid to compute the next 1000 dates, which can take time)
3/ Fill first issue publication date
4/ Choose the frequency you want to test
5/ click on "Test pattern" button
6/ Check that the dates are correct
7/ Repeat steps 3-7 until you think you have tested enough cases

Interesting frequencies to test:
- 1/day
- 1/week
- 2/week
- 6/week (firstacquidate should be monday or tuesday, or the generated
  dates will be the same for all the week)
- 1/month
- 2/month
- 3/month
- 1/year
- 2/year
- 3/year

----------------
Sign off report:
----------------
-Followed the test plan. Unit tests work. Also trying some more strange
 frequencies with our librarians:
 5/year, 43/year, 10/year.
-Received all serials for a subscription and found no errors.
-Received some serials with frequency 2/month pre-patch, getting publication
 date as 1st of every month for each magazine. Having applied the patch,
 publication dates started working mid-subscription for new magazines.
-Works well and fine!
Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 16 Kyle M Hall 2015-03-27 18:37:29 UTC
Created attachment 37342 [details] [review]
[PASSED QA] Bug 12671: Guess next serial date when there are several issues per unit. Added support for real month and year lenghts.

When getting the next frequency number, use the real number of days for each month and each year.

Unit tests updated.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 17 Tomás Cohen Arazi 2015-05-05 18:43:55 UTC
Patches pushed to master.

Good job Julian!