Bug 16122 - Item record needs to keep local use count
Summary: Item record needs to keep local use count
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Lucas Gass (lukeg)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
: 18668 (view as bug list)
Depends on: 33568 35840 35950 33500
Blocks: 36709 37790
  Show dependency treegraph
 
Reported: 2016-03-22 15:46 UTC by Christopher Brannon
Modified: 2024-08-30 15:43 UTC (History)
15 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch adds a new separate field for recording local use to the items table. It will be hidden from the holdings table by default but can be made visible using the table configuration settings. This includes a new CLI script to update the `update_localuse_from_statistics.pl` that can be used to set the new items.localuse field with information from the statistics table.
Version(s) released in:
24.05.00
Circulation function:


Attachments
Bug 16122: Add localuse column to items and deleteditems (3.38 KB, patch)
2023-04-07 16:33 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.50 KB, patch)
2023-04-07 16:51 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.10 KB, patch)
2023-04-07 16:58 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display to holdings/otherholdings and Table settings (3.37 KB, patch)
2023-04-07 17:06 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment localuse when checking out to stats patron (886 bytes, patch)
2023-04-25 22:30 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.44 KB, patch)
2023-04-25 23:12 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.55 KB, patch)
2023-04-25 23:12 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.16 KB, patch)
2023-04-25 23:12 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Add display to holdings/otherholdings and Table settings (3.43 KB, patch)
2023-04-25 23:12 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Increment localuse when checking out to stats patron (947 bytes, patch)
2023-04-25 23:12 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.78 KB, patch)
2023-05-03 23:26 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.60 KB, patch)
2023-05-04 19:46 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display and increment localuse (3.92 KB, patch)
2023-07-07 16:27 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.51 KB, patch)
2023-07-07 16:55 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.62 KB, patch)
2023-07-07 16:55 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.23 KB, patch)
2023-07-07 16:55 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.67 KB, patch)
2023-07-07 16:55 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 16122: Add display and increment localuse (3.99 KB, patch)
2023-07-07 16:55 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.57 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.68 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.29 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.73 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: Add display and increment localuse (4.04 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: (QA follow-up) Perltidy, fix spelling and db comments (5.66 KB, patch)
2023-11-05 13:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.57 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.68 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.67 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.28 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.73 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Perltidy and spelling (4.67 KB, patch)
2024-01-12 23:11 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.57 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.68 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.67 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.29 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.73 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Perltidy and spelling (4.67 KB, patch)
2024-01-18 18:32 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: AddReturn unit tests and small fix in sub AddReturn (2.57 KB, patch)
2024-01-18 19:17 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: CanBookBeIssued unit test (2.14 KB, patch)
2024-01-18 20:00 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.63 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.74 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse in AddReturn (1.73 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.35 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.79 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Perltidy and spelling (4.73 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: AddReturn unit tests and small fix in sub AddReturn (2.63 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: CanBookBeIssued unit test (2.20 KB, patch)
2024-01-18 22:31 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.73 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.74 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse (1.65 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.35 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.79 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add unit test (3.15 KB, patch)
2024-03-11 23:37 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.79 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.80 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse (1.71 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.41 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.85 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: Add unit test (3.21 KB, patch)
2024-03-15 14:32 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.86 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.87 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse (1.77 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (3.47 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.91 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Add unit test (3.28 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Tidy changed code blocks (5.90 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Add note to database update to point out new script (1.01 KB, patch)
2024-03-18 10:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 16122: Add localuse column to items and deleteditems (3.85 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: API and Schema updates (2.86 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Increment items.localuse (1.77 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add display and Table settings (2.98 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add maintenance script to update items.localuse from stats (2.91 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add unit test (3.27 KB, patch)
2024-04-22 15:35 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Tidy changed code blocks (5.89 KB, patch)
2024-04-22 15:36 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 16122: Add note to database update to point out new script (1.01 KB, patch)
2024-04-22 15:36 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Brannon 2016-03-22 15:46:06 UTC
Like the "issues" field in the items table, there should be a field for "local_use" to keep the count of local uses.  While this information is kept in the statistics table, it is a task to acquire, and if a library wants to keep bloat down on their tables, the statistics are pruned on a regular schedule, which means loss of valuable data.  This counter would keep that valuable information in one field in each item record, rather than having a separate field for each instance in the statistics table.

Unless it is vital to someone to know the exact moment a local use occurred, I am suggesting that this piece of information not be recorded in the statistics table any longer.  This would significantly reduce the growth of the statistics table in general.

Christopher
Comment 1 Katrin Fischer 2016-03-22 20:35:10 UTC
I think an option would be ok, but I am against removing it - the local use information in statistics will allow to look up the timeframe (local uses in the last x months, years...) which is useful information.
Comment 2 Christopher Brannon 2016-03-22 21:02:36 UTC
Perhaps a switch to turn the statistic on/off?  But add the counter to the record.
Comment 3 Katrin Fischer 2016-03-22 21:04:52 UTC
Could work :)
Comment 4 Andrew Fuerste-Henry 2019-06-12 14:42:18 UTC
I absolutely agree if would be handy to have a local use number in the record -- and then to show that number on moredetail.pl.

But I also agree with Katrin that I don't see why we would remove those transactions from the statistics table.
Comment 5 Christopher Brannon 2019-06-12 15:15:22 UTC
Read the second paragraph.  It addresses this question.
Comment 6 Katrin Fischer 2019-06-18 22:16:16 UTC
My feeling is that a simple counter loses meaning the longer you keep the data.

What's better? 5 local uses in 10 years or 5 in one? With a simple counter, there is no way to tell. I think issues might give an indicator about 'use' of the book (when you might want to replace it), but not sure the local_use is interesting in the same way. 

That said, we could split the circulation log preference to not record.

Is the size of the data in statistics really that much of an issue? I seem to remember that some libraries have kept their data without pruning ever and have to say we don't prune either and have some systems running for almost 10 years now. It's only used for statistics, so it doesn't slow anything down.
Comment 7 Christopher Brannon 2019-06-19 14:24:32 UTC
The bigger the system, the more data you have to sift through, and it can make reports very sluggish.

I'd be fine if it were kept in the logs, if there were some mechanism that could prune the logs of items that are deleted, and the pruning could be fine tuned as needed.
Comment 8 Katrin Fischer 2019-06-20 14:17:15 UTC
I get a feeling that opinions on the stats tables vary wildly. As I said, I would not prune them, but only anonymize them if necessary. Having an idea about when something happened seems important to me. Having jobs with different options make sense.

BTW: as far as I know it won't free space with MySQL if you delete lines. So that should not be a reason?
Comment 9 Andrew Fuerste-Henry 2022-07-20 13:58:07 UTC
*** Bug 18668 has been marked as a duplicate of this bug. ***
Comment 10 Lucas Gass (lukeg) 2023-04-07 16:33:14 UTC
Created attachment 149281 [details] [review]
Bug 16122: Add localuse column to items and deleteditems
Comment 11 Lucas Gass (lukeg) 2023-04-07 16:51:35 UTC
Created attachment 149282 [details] [review]
Bug 16122: API and Schema updates
Comment 12 Lucas Gass (lukeg) 2023-04-07 16:58:09 UTC
Created attachment 149283 [details] [review]
Bug 16122: Increment items.localuse in AddReturn
Comment 13 Lucas Gass (lukeg) 2023-04-07 17:06:24 UTC
Created attachment 149284 [details] [review]
Bug 16122: Add display to holdings/otherholdings and Table settings
Comment 14 Lucas Gass (lukeg) 2023-04-07 17:14:45 UTC
I've added some patches that will add an items.localuse column to the items table and also display this in the holdings/other holdings table. 

Leaving as assigned as this will still need adjusted/updated tests. 

Not sure how to deal with the information that is already available via statistics. I really think we should leave the statistics table as is. However we may need a script or DB update that will make the new items.localuse column congruent with what can be derived from statistics.
Comment 15 Christopher Brannon 2023-04-07 18:55:32 UTC
(In reply to Lucas Gass from comment #14)
> I've added some patches that will add an items.localuse column to the items
> table and also display this in the holdings/other holdings table. 
> 
> Leaving as assigned as this will still need adjusted/updated tests. 
> 
> Not sure how to deal with the information that is already available via
> statistics. I really think we should leave the statistics table as is.
> However we may need a script or DB update that will make the new
> items.localuse column congruent with what can be derived from statistics.

In my opinion, it would be good to have an option to convert those stats over to the new counters.  It would also be good to have the option to clear out those stats from the statistics table once converted.
Comment 16 Christopher Brannon 2023-04-07 18:59:04 UTC
(In reply to Katrin Fischer from comment #8)
> I get a feeling that opinions on the stats tables vary wildly. As I said, I
> would not prune them, but only anonymize them if necessary. Having an idea
> about when something happened seems important to me. Having jobs with
> different options make sense.
> 
> BTW: as far as I know it won't free space with MySQL if you delete lines. So
> that should not be a reason?

Hmmmm...this is news to me.  I've always known data to take up space.  Not sure how you can remove lines of data and not free up space.  That is a huge problem if that is the case.
Comment 17 Christopher Brannon 2023-04-07 19:00:26 UTC
(In reply to Lucas Gass from comment #14)
> I've added some patches that will add an items.localuse column to the items
> table and also display this in the holdings/other holdings table. 
> 
> Leaving as assigned as this will still need adjusted/updated tests. 
> 
> Not sure how to deal with the information that is already available via
> statistics. I really think we should leave the statistics table as is.
> However we may need a script or DB update that will make the new
> items.localuse column congruent with what can be derived from statistics.

I should clarify, it would be good to at least capture the existing stats and convert them to the counters before those stats are eliminated through table clean up.
Comment 18 Katrin Fischer 2023-04-08 15:40:30 UTC
(In reply to Christopher Brannon from comment #17)
> (In reply to Lucas Gass from comment #14)
> > I've added some patches that will add an items.localuse column to the items
> > table and also display this in the holdings/other holdings table. 
> > 
> > Leaving as assigned as this will still need adjusted/updated tests. 
> > 
> > Not sure how to deal with the information that is already available via
> > statistics. I really think we should leave the statistics table as is.
> > However we may need a script or DB update that will make the new
> > items.localuse column congruent with what can be derived from statistics.
> 
> I should clarify, it would be good to at least capture the existing stats
> and convert them to the counters before those stats are eliminated through
> table clean up.

https://stackoverflow.com/questions/1270944/mysql-innodb-not-releasing-disk-space-after-deleting-data-rows-from-table
Comment 19 Christopher Brannon 2023-04-08 15:46:09 UTC
(In reply to Katrin Fischer from comment #18)
> (In reply to Christopher Brannon from comment #17)
> > (In reply to Lucas Gass from comment #14)
> > > I've added some patches that will add an items.localuse column to the items
> > > table and also display this in the holdings/other holdings table. 
> > > 
> > > Leaving as assigned as this will still need adjusted/updated tests. 
> > > 
> > > Not sure how to deal with the information that is already available via
> > > statistics. I really think we should leave the statistics table as is.
> > > However we may need a script or DB update that will make the new
> > > items.localuse column congruent with what can be derived from statistics.
> > 
> > I should clarify, it would be good to at least capture the existing stats
> > and convert them to the counters before those stats are eliminated through
> > table clean up.
> 
> https://stackoverflow.com/questions/1270944/mysql-innodb-not-releasing-disk-
> space-after-deleting-data-rows-from-table

Well, that is just insane.  REGARDLESS, I know for a fact that table queries on smaller tables run faster.  Tables must be pruned on a regular basis to maintain optimal performance.  This bug will ensure needed data is maintained over time.
Comment 20 Lucas Gass (lukeg) 2023-04-25 22:30:44 UTC
Created attachment 150231 [details] [review]
Bug 16122: Increment localuse when checking out to stats patron
Comment 21 Lucas Gass (lukeg) 2023-04-25 22:37:09 UTC
TEST PLAN:

To test:
1. Apply patch, updatedatabase & schema, restart all Services 
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on. 
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off. 
5. Check in an item that is not checkout out. No local use should be recorded for the item. 
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1. 
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.
Comment 22 Biblibre Sandboxes 2023-04-25 23:12:13 UTC
Created attachment 150232 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Comment 23 Biblibre Sandboxes 2023-04-25 23:12:15 UTC
Created attachment 150233 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Comment 24 Biblibre Sandboxes 2023-04-25 23:12:17 UTC
Created attachment 150234 [details] [review]
Bug 16122: Increment items.localuse in AddReturn

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Comment 25 Biblibre Sandboxes 2023-04-25 23:12:20 UTC
Created attachment 150235 [details] [review]
Bug 16122: Add display to holdings/otherholdings and Table settings

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Comment 26 Biblibre Sandboxes 2023-04-25 23:12:22 UTC
Created attachment 150236 [details] [review]
Bug 16122: Increment localuse when checking out to stats patron

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Comment 27 Christopher Brannon 2023-04-25 23:12:55 UTC
Works like a charm!  Cool beans!
Comment 28 Andrew Fuerste-Henry 2023-04-26 13:23:25 UTC
FYI, I filed bug 32440 suggesting cleanup_database get enhanced to allow selective deletion from statistics based on type. Right now (per bug 19008) cleanup_database can delete all statistics entries older than a specified interval, but it makes sense to me to allow an additional constraint based on statistics.type.
Comment 29 Lucas Gass (lukeg) 2023-04-26 14:00:26 UTC
Christopher,

Thanks for you sign-off! I do need to reset this one to ASSIGNED as it still needs some work.

-Unit tests
-Need to figure out what to do about the existing data in the stats table
Comment 30 Lucas Gass (lukeg) 2023-05-03 23:26:54 UTC
Created attachment 150623 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats
Comment 31 Lucas Gass (lukeg) 2023-05-04 19:46:21 UTC
Created attachment 150693 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats
Comment 32 Emily Lamancusa (emlam) 2023-06-16 15:49:36 UTC
Lucas, can you provide a test plan for that last patch? If so I'd be happy to sign off.
Comment 33 Emily Lamancusa (emlam) 2023-06-26 20:17:30 UTC
Tried to test this, but the patch does not apply.

Applying: Bug 16122: Add localuse column to items and deleteditems
Applying: Bug 16122: API and Schema updates
Applying: Bug 16122: Increment items.localuse in AddReturn
Applying: Bug 16122: Add display to holdings/otherholdings and Table settings
Using index info to reconstruct a base tree...
M	admin/columns_settings.yml
M	koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
Auto-merging admin/columns_settings.yml
Applying: Bug 16122: Increment localuse when checking out to stats patron
error: sha1 information is lacking or useless (C4/Circulation.pm).
error: could not build fake ancestor
Patch failed at 0001 Bug 16122: Increment localuse when checking out to stats patron
Comment 34 Lucas Gass (lukeg) 2023-06-28 21:13:46 UTC
(In reply to Emily Lamancusa from comment #33)
> Tried to test this, but the patch does not apply.
> 
> Applying: Bug 16122: Add localuse column to items and deleteditems
> Applying: Bug 16122: API and Schema updates
> Applying: Bug 16122: Increment items.localuse in AddReturn
> Applying: Bug 16122: Add display to holdings/otherholdings and Table settings
> Using index info to reconstruct a base tree...
> M	admin/columns_settings.yml
> M	koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
> Falling back to patching base and 3-way merge...
> Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
> Auto-merging admin/columns_settings.yml
> Applying: Bug 16122: Increment localuse when checking out to stats patron
> error: sha1 information is lacking or useless (C4/Circulation.pm).
> error: could not build fake ancestor
> Patch failed at 0001 Bug 16122: Increment localuse when checking out to
> stats patron

This still applies cleanly for me.
Comment 35 Lucas Gass (lukeg) 2023-06-28 21:18:35 UTC
(In reply to Emily Lamancusa from comment #32)
> Lucas, can you provide a test plan for that last patch? If so I'd be happy
> to sign off.

To test:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table 

Using this report can help:

SELECT COUNT( IF( statistics.type = 'localuse', statistics.itemnumber, NULL ) )  AS 'local use count'
FROM statistics
WHERE statistics.itemnumber=<<itemnumber>>
Comment 36 Emily Lamancusa (emlam) 2023-06-29 15:36:02 UTC
Hmmm, I'm still getting the error when I try to apply it.
Comment 37 Katrin Fischer 2023-06-30 17:23:19 UTC
Hi Lucas, I am having the same issue as Emily on current master:

Applying: Bug 16122: Add display to holdings/otherholdings and Table settings
Using index info to reconstruct a base tree...
M	admin/columns_settings.yml
M	koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
Auto-merging admin/columns_settings.yml
Applying: Bug 16122: Increment localuse when checking out to stats patron
error: sha1 information is lacking or useless (C4/Circulation.pm).
error: could not build fake ancestor
Patch failed at 0001 Bug 16122: Increment localuse when checking out to stats patron
hint: Use 'git am --show-current-patch=diff' to see the failed 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-16122-Increment-localuse-when-checking-out-to--o5eeizs8.patch


We might be missing something that is in your repository.
Comment 38 Lucas Gass (lukeg) 2023-07-07 16:27:08 UTC
Created attachment 153193 [details] [review]
Bug 16122: Add display and increment localuse
Comment 39 Lucas Gass (lukeg) 2023-07-07 16:30:46 UTC
rebased for current master
Comment 40 Emily Lamancusa (emlam) 2023-07-07 16:55:24 UTC
Created attachment 153196 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 41 Emily Lamancusa (emlam) 2023-07-07 16:55:27 UTC
Created attachment 153197 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 42 Emily Lamancusa (emlam) 2023-07-07 16:55:30 UTC
Created attachment 153198 [details] [review]
Bug 16122: Increment items.localuse in AddReturn

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 43 Emily Lamancusa (emlam) 2023-07-07 16:55:32 UTC
Created attachment 153199 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 44 Emily Lamancusa (emlam) 2023-07-07 16:55:35 UTC
Created attachment 153200 [details] [review]
Bug 16122: Add display and increment localuse

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 45 Steve, OSLRI, USA 2023-09-06 21:13:36 UTC
+1 for items.localuse counter field from Ocean State Libraries.
Comment 46 Laura Escamilla 2023-10-17 20:20:21 UTC
+1
Comment 47 Lucas Gass (lukeg) 2023-11-02 17:32:06 UTC
This still applies cleanly, what would it take to get some QA eyes on it?
Comment 48 Katrin Fischer 2023-11-02 18:53:57 UTC
(In reply to Lucas Gass from comment #47)
> This still applies cleanly, what would it take to get some QA eyes on it?

Stop commenting so it goes down in the list - I have been working on bugs first and oldest next ;)
Comment 49 Lucas Gass (lukeg) 2023-11-02 20:22:58 UTC
(In reply to Katrin Fischer from comment #48)
> (In reply to Lucas Gass from comment #47)
> > This still applies cleanly, what would it take to get some QA eyes on it?
> 
> Stop commenting so it goes down in the list - I have been working on bugs
> first and oldest next ;)

Ha. fair enough! :)
Comment 50 Katrin Fischer 2023-11-05 13:01:22 UTC
Created attachment 158466 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 51 Katrin Fischer 2023-11-05 13:01:26 UTC
Created attachment 158467 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 52 Katrin Fischer 2023-11-05 13:01:30 UTC
Created attachment 158468 [details] [review]
Bug 16122: Increment items.localuse in AddReturn

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 53 Katrin Fischer 2023-11-05 13:01:33 UTC
Created attachment 158469 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 54 Katrin Fischer 2023-11-05 13:01:37 UTC
Created attachment 158470 [details] [review]
Bug 16122: Add display and increment localuse

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 55 Katrin Fischer 2023-11-05 13:01:41 UTC
Created attachment 158471 [details] [review]
Bug 16122: (QA follow-up) Perltidy, fix spelling and db comments

* COMMENT in database update and kohastructure didn't match up
* Fix some localuse to local use in text/descriptions
* Perltidy

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 56 Katrin Fischer 2023-11-05 13:01:54 UTC
**ATTENTION**

We might want to push the bugfix from bug 27992 first, although it might create a small conflict in Circulation.pm here.


1) QA test script

Still applies, but requires perltidy:

 WARN	C4/Circulation.pm
   WARN	  tidiness
		The file is less tidy than before (bad/messy lines before: 1104, now: 1108)

 WARN	installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl
   WARN	  tidiness
		The file is less tidy than before (bad/messy lines before: 0, now: 10)

 WARN	misc/maintenance/update_localuse_from_statistics.pl
   WARN	  tidiness
		The file is less tidy than before (bad/messy lines before: 0, now: 8)

Fixed in a follow-up. 

Also fixed:

* COMMENT in database update and kohastructure didn't match up
* some spelling

2) We need unit tests. (blocker)

3) Column configuration page for items table on detail page needs to be updated. 
Suggestion: I'd hide this column by default for existing and new installations to not grow the items table.

4) Maintenance script

+use strict;
+use warnings;

Should be: use Modern::Perl;

It feels like this should have a verbose option and maybe a warning/hint that existing entries in items will be overwritten?
Comment 57 Katrin Fischer 2023-11-05 13:02:56 UTC
Will still need to test some more once we have the tests.
Comment 58 Lucas Gass (lukeg) 2024-01-12 23:11:14 UTC
Created attachment 161001 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 59 Lucas Gass (lukeg) 2024-01-12 23:11:17 UTC
Created attachment 161002 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 60 Lucas Gass (lukeg) 2024-01-12 23:11:20 UTC
Created attachment 161003 [details] [review]
Bug 16122: Increment items.localuse in AddReturn
Comment 61 Lucas Gass (lukeg) 2024-01-12 23:11:23 UTC
Created attachment 161004 [details] [review]
Bug 16122: Add display and Table settings
Comment 62 Lucas Gass (lukeg) 2024-01-12 23:11:26 UTC
Created attachment 161005 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 63 Lucas Gass (lukeg) 2024-01-12 23:11:29 UTC
Created attachment 161006 [details] [review]
Bug 16122: Perltidy and spelling

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table
Comment 64 Lucas Gass (lukeg) 2024-01-18 18:32:17 UTC
Created attachment 161144 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 65 Lucas Gass (lukeg) 2024-01-18 18:32:20 UTC
Created attachment 161145 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 66 Lucas Gass (lukeg) 2024-01-18 18:32:23 UTC
Created attachment 161146 [details] [review]
Bug 16122: Increment items.localuse in AddReturn
Comment 67 Lucas Gass (lukeg) 2024-01-18 18:32:26 UTC
Created attachment 161147 [details] [review]
Bug 16122: Add display and Table settings
Comment 68 Lucas Gass (lukeg) 2024-01-18 18:32:28 UTC
Created attachment 161148 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 69 Lucas Gass (lukeg) 2024-01-18 18:32:32 UTC
Created attachment 161149 [details] [review]
Bug 16122: Perltidy and spelling

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table
Comment 70 Lucas Gass (lukeg) 2024-01-18 19:17:18 UTC
Created attachment 161150 [details] [review]
Bug 16122: AddReturn unit tests and small fix in sub AddReturn
Comment 71 Lucas Gass (lukeg) 2024-01-18 20:00:51 UTC
Created attachment 161151 [details] [review]
Bug 16122: CanBookBeIssued unit test
Comment 72 Andrew Fuerste-Henry 2024-01-18 22:30:35 UTC
When I have RecordLocalUseOnCheckin enabled and check an item out to a statistical patron, Local Use for that item goes up by 2. That seems wrong, but also doesn't appear to be new, exactly. Without this patch, if I have RecordLocalUseOnCheckin enabled and check an item out to a statistical patron I get 2 local use lines in statistics. I'm going to file a new bug for this issue, I only mention it here because I almost marked this one Failed QA thinking it was new behavior rather than old behavior made more obvious.
Comment 73 Biblibre Sandboxes 2024-01-18 22:31:07 UTC
Created attachment 161153 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 74 Biblibre Sandboxes 2024-01-18 22:31:11 UTC
Created attachment 161154 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 75 Biblibre Sandboxes 2024-01-18 22:31:14 UTC
Created attachment 161155 [details] [review]
Bug 16122: Increment items.localuse in AddReturn

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 76 Biblibre Sandboxes 2024-01-18 22:31:17 UTC
Created attachment 161156 [details] [review]
Bug 16122: Add display and Table settings

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 77 Biblibre Sandboxes 2024-01-18 22:31:20 UTC
Created attachment 161157 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 78 Biblibre Sandboxes 2024-01-18 22:31:23 UTC
Created attachment 161158 [details] [review]
Bug 16122: Perltidy and spelling

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 79 Biblibre Sandboxes 2024-01-18 22:31:27 UTC
Created attachment 161159 [details] [review]
Bug 16122: AddReturn unit tests and small fix in sub AddReturn

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 80 Biblibre Sandboxes 2024-01-18 22:31:30 UTC
Created attachment 161160 [details] [review]
Bug 16122: CanBookBeIssued unit test

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 81 Lucas Gass (lukeg) 2024-01-19 15:41:47 UTC
(In reply to Andrew Fuerste-Henry from comment #72)
> When I have RecordLocalUseOnCheckin enabled and check an item out to a
> statistical patron, Local Use for that item goes up by 2. That seems wrong,
> but also doesn't appear to be new, exactly. Without this patch, if I have
> RecordLocalUseOnCheckin enabled and check an item out to a statistical
> patron I get 2 local use lines in statistics. I'm going to file a new bug
> for this issue, I only mention it here because I almost marked this one
> Failed QA thinking it was new behavior rather than old behavior made more
> obvious.

Thanks Andrew! I have added a patch to Bug 35840 in an attempt to fix this issue.
Comment 82 Lucas Gass (lukeg) 2024-01-19 23:16:13 UTC
This needs to be BLOCKED until Bug 35840 moves.
Comment 83 Lucas Gass (lukeg) 2024-03-11 16:56:39 UTC
Needs rebased/refactored on top of Bug 35950.
Comment 84 Lucas Gass (lukeg) 2024-03-11 23:37:34 UTC
Created attachment 163072 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 85 Lucas Gass (lukeg) 2024-03-11 23:37:37 UTC
Created attachment 163073 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 86 Lucas Gass (lukeg) 2024-03-11 23:37:40 UTC
Created attachment 163074 [details] [review]
Bug 16122: Increment items.localuse
Comment 87 Lucas Gass (lukeg) 2024-03-11 23:37:43 UTC
Created attachment 163075 [details] [review]
Bug 16122: Add display and Table settings

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 88 Lucas Gass (lukeg) 2024-03-11 23:37:46 UTC
Created attachment 163076 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Comment 89 Lucas Gass (lukeg) 2024-03-11 23:37:49 UTC
Created attachment 163077 [details] [review]
Bug 16122: Add unit test

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table
Comment 90 Andrew Fuerste-Henry 2024-03-15 14:32:36 UTC
Created attachment 163243 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 91 Andrew Fuerste-Henry 2024-03-15 14:32:39 UTC
Created attachment 163244 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 92 Andrew Fuerste-Henry 2024-03-15 14:32:42 UTC
Created attachment 163245 [details] [review]
Bug 16122: Increment items.localuse

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 93 Andrew Fuerste-Henry 2024-03-15 14:32:45 UTC
Created attachment 163246 [details] [review]
Bug 16122: Add display and Table settings

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 94 Andrew Fuerste-Henry 2024-03-15 14:32:48 UTC
Created attachment 163247 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 95 Andrew Fuerste-Henry 2024-03-15 14:32:51 UTC
Created attachment 163248 [details] [review]
Bug 16122: Add unit test

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Comment 96 Martin Renvoize (ashimema) 2024-03-18 10:17:23 UTC
Created attachment 163296 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 97 Martin Renvoize (ashimema) 2024-03-18 10:17:27 UTC
Created attachment 163297 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 98 Martin Renvoize (ashimema) 2024-03-18 10:17:31 UTC
Created attachment 163298 [details] [review]
Bug 16122: Increment items.localuse

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 99 Martin Renvoize (ashimema) 2024-03-18 10:17:35 UTC
Created attachment 163299 [details] [review]
Bug 16122: Add display and Table settings

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 100 Martin Renvoize (ashimema) 2024-03-18 10:17:39 UTC
Created attachment 163300 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 101 Martin Renvoize (ashimema) 2024-03-18 10:17:43 UTC
Created attachment 163301 [details] [review]
Bug 16122: Add unit test

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 102 Martin Renvoize (ashimema) 2024-03-18 10:17:47 UTC
Created attachment 163302 [details] [review]
Bug 16122: Tidy changed code blocks

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 103 Martin Renvoize (ashimema) 2024-03-18 10:17:51 UTC
Created attachment 163303 [details] [review]
Bug 16122: Add note to database update to point out new script

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 104 Martin Renvoize (ashimema) 2024-03-18 10:18:44 UTC
All works as designed, QA scripts are happy, tests are passing and new coverage is added.

Passing QA, well perserverred Lucas!
Comment 105 Katrin Fischer 2024-04-22 06:18:56 UTC
I am sorry, but the detail page requires some more work due to:

Bug 33568 - Use the REST API to display items on the biblio detail view

Please rebase and push back into my queue.
Comment 106 Lucas Gass (lukeg) 2024-04-22 15:35:41 UTC
Created attachment 165313 [details] [review]
Bug 16122: Add localuse column to items and deleteditems

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 107 Lucas Gass (lukeg) 2024-04-22 15:35:45 UTC
Created attachment 165314 [details] [review]
Bug 16122: API and Schema updates

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 108 Lucas Gass (lukeg) 2024-04-22 15:35:48 UTC
Created attachment 165315 [details] [review]
Bug 16122: Increment items.localuse

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 109 Lucas Gass (lukeg) 2024-04-22 15:35:51 UTC
Created attachment 165316 [details] [review]
Bug 16122: Add display and Table settings

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 110 Lucas Gass (lukeg) 2024-04-22 15:35:54 UTC
Created attachment 165317 [details] [review]
Bug 16122: Add maintenance script to update items.localuse from stats

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 111 Lucas Gass (lukeg) 2024-04-22 15:35:57 UTC
Created attachment 165318 [details] [review]
Bug 16122: Add unit test

To test:
1. Apply patch, updatedatabase & schema, restart all Services
2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on.
3. Go to an item record and notice the column 'Local uses'
4. Turn the system preference RecordLocalUseOnReturn Off.
5. Check in an item that is not checkout out. No local use should be recorded for the item.
6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1.
7. Create a statistical patron and check an item out to them. Local use should increment by 1.
8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct.

To test maintainence script:
1. Without the patch, have RecordLocalUseOnReturn on.
2. Check in some items to record localuse in the stats table. Keep note of those stats.
3. Apply the patches, updatedatabase.
4. Run the maintenance script, perl update_localuse_from_statistics.pl
5. Now check that items.localuse is congruent with what is in the stats table

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 112 Lucas Gass (lukeg) 2024-04-22 15:36:00 UTC
Created attachment 165319 [details] [review]
Bug 16122: Tidy changed code blocks

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 113 Lucas Gass (lukeg) 2024-04-22 15:36:04 UTC
Created attachment 165320 [details] [review]
Bug 16122: Add note to database update to point out new script

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 114 Lucas Gass (lukeg) 2024-04-22 15:36:44 UTC
rebased for current main and back to PQA.
Comment 115 Katrin Fischer 2024-04-26 12:08:58 UTC
Hm, DBIC changes here are mixed in with other changes, so I have kept the patch. dbic comes up empty. I have been told it would be better to regenerate usually so timestamps etc. match
Comment 116 Katrin Fischer 2024-04-26 12:10:42 UTC
I am a fan of scripts that update data having a --confirm switch, this one just has the -h. I know that you should always run the latter first, so leaving this more as a note and suggestion.
Comment 117 Katrin Fischer 2024-04-26 12:16:41 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 118 Katrin Fischer 2024-04-26 14:06:13 UTC
(In reply to Katrin Fischer from comment #115)
> Hm, DBIC changes here are mixed in with other changes, so I have kept the
> patch. dbic comes up empty. I have been told it would be better to
> regenerate usually so timestamps etc. match

I just figured out what happens when you don't run dbic again - it causes issues! - please only strictly separate patches in future! :)
Comment 119 Lucas Gass (lukeg) 2024-04-26 14:08:22 UTC
(In reply to Katrin Fischer from comment #116)
> I am a fan of scripts that update data having a --confirm switch, this one
> just has the -h. I know that you should always run the latter first, so
> leaving this more as a note and suggestion.

I will add a confirm flag:

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36709
Comment 120 Lucas Gass (lukeg) 2024-04-26 14:08:46 UTC
(In reply to Katrin Fischer from comment #118)
> (In reply to Katrin Fischer from comment #115)
> > Hm, DBIC changes here are mixed in with other changes, so I have kept the
> > patch. dbic comes up empty. I have been told it would be better to
> > regenerate usually so timestamps etc. match
> 
> I just figured out what happens when you don't run dbic again - it causes
> issues! - please only strictly separate patches in future! :)

Noted. Thanks!
Comment 121 Fridolin Somers 2024-05-24 07:49:26 UTC
Not backported to 23.11.x