Bug 36201

Summary: Add -days_old and -months_old arguments for misc/export_records.pl
Product: Koha Reporter: Alex Buckley <alexbuckley>
Component: CatalogingAssignee: Alex Buckley <alexbuckley>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: baptiste.bayche, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 36201: Add -days_old and -months_old arguments to misc/export_records.pl

Description Alex Buckley 2024-02-29 03:32:14 UTC
It would be nice if libraries could use misc/export_records.pl as a cronjob to run on the first day of every month to export all new biblio records added in the last month: by using new -days_old=31 or -months_old=1 arguments for the export_records.pl script to limit on the biblio.datecreated. 

A use case for this would be those libraries which need to keep a union catalogue up to date with their local Koha catalogue. By providing the union catalogue provider with a MARC file of all biblio additions in the last month.
Comment 1 Alex Buckley 2024-02-29 03:57:46 UTC
Created attachment 162575 [details] [review]
Bug 36201: Add -days_old and -months_old arguments to misc/export_records.pl

Limit exported records based on the biblio.datecreated using the
-days_old and -months_old arguments.

Test plan:
1. Remove all biblios in your Koha catalogue, then create 10 bibliographic records - in the Koha database set 6 of the biblios to have a biblio.datecreated 50 days ago

2. Apply patches and restart services

3. In koha-shell run the following command:
perl misc/export_records.pl  --months_old=1 --format=marc --record-type=bibs --filename=/tmp/test.mrc

4. Check the /tmp/test.mrc and confirm it has 4 biblios in it

5. In the koha-shell run the following command:
perl misc/export_records.pl  --days_old=31 --format=marc --record-type=bibs --filename=/tmp/test2.mrc

6. Check the /tmp/test2.mrc and confirm it also has 4 biblios in it

7. In the koha-shell run the following command:
perl misc/export_records.pl  --days_old=52 --format=marc --record-type=bibs --filename=/tmp/test3.mrc

8. Check the /tmp/test3.mrc and confirm it has 10 biblios in it

9. In the koha-shell run the following command:
perl misc/export_records.pl  --format=marc --record-type=bibs --filename=/tmp/all.mrc

10. Check the /tmp/all.mrc and confirm it also has 10 biblios in it

11. Try running the export_records.pl script with a variety of other
arguments and confirm it works as expected

Sponsored-By: Department of Corrections, New Zealand
Comment 2 Alex Buckley 2024-02-29 04:15:19 UTC
Ready to test
Comment 3 Alex Buckley 2025-01-10 01:47:49 UTC
Since we have upstreamed the ability to run export_records.pl off a SQL report in bug 36770 ( https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36770 ) this bug report is redundant, because you could just add these conditionals as a SQL WHERE clause in your SQL report.

*** This bug has been marked as a duplicate of bug 36770

*** This bug has been marked as a duplicate of bug 36770 ***