Bug 32487

Summary: Cronjob to delete records with no items
Product: Koha Reporter: Aleisha Amohia <aleisha>
Component: Command-line UtilitiesAssignee: Aleisha Amohia <aleisha>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, dcook, emmi.takkinen, robin
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: Sponsored Comma delimited list of Sponsors:
Crowdfunding goal: 0 Crowdfunding committed: 0
Crowdfunding contact: Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Aleisha Amohia 2022-12-19 03:50:59 UTC
We've been requested to develop a cronjob to clear out bibliographic records with no items. This could be useful if there's a duplicate record where items are being attached, so the other record is empty and not being used in Koha, just crowding search results.
Comment 1 Andrew Fuerste-Henry 2022-12-19 17:18:10 UTC
It'd be great if this included some way to exclude some itemless bibs, for libraries that include bibs for ebooks without attached item records. Maybe an option to exclude certain biblio-itemtypes from the deletion? Or to exclude bibs with something in the 856?
Comment 2 Katrin Fischer 2022-12-19 17:32:02 UTC
There are actually quite a lot of cases that come to mind, where a record has no items but is still wanted/needed:

* Set type records for multi-volumes
* Series type records for traced series
* Records where the item is linked using EasyAnalytics
* Analytical records using 773 standard linking
* Serials where the library has subscriptions and issues, but doesn't create items
* Acquisition records where the library doesn't attach items or new standing order records
* Electronic resources - 856 might not be best, as it could also be some other type of content enrichment like a scanned TOC. Maybe 007, Pos. 0? https://www.loc.gov/marc/bibliographic/bd007.html

Maybe an option: add a --WHERE SQL condition option to the existing batchdeletebiblios.pl. 

This way it would allow libraries to easily specifiy "has no items", without going into the rabbit hole of discussing all the above cases. Keeping it simple.
Comment 3 David Cook 2022-12-19 22:15:51 UTC
Locally we handle this scenario using a custom report page where librarians can review bib records with no items attached. 

They'll often exclude electronic resources by item type. 

It's a more manual process than a cronjob, but it's less error prone I think.
Comment 4 Aleisha Amohia 2023-01-10 04:04:37 UTC
Thanks all for your discussion.

I ended up using cronjobs/runreport.pl to run a report fetching the biblionumbers of biblios with no items, piping those results into a file, then giving that file to batchdeletebiblios.pl.

I'll close this bug report now.