Bug 24348

Summary: Record matching rules: required match checks does not work
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: MARC Bibliographic record staging/importAssignee: Andreas Jonsson <andreas.jonsson>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: 1joynelson, hayleypelham, jonathan.druart, lucas, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.03, 19.05.08
Circulation function:
Bug Depends on: 22046    
Bug Blocks:    
Attachments: Bug 24348: Pass marc record to _passes_required_checks
Bug 24348: Pass marc record to _passes_required_checks
Bug 24348: Pass marc record to _passes_required_checks

Description Andreas Jonsson 2020-01-05 13:00:34 UTC
The required match checks where broken by commit 53545ba739e1706da7f3e52c145f0f6c8bbfb18c of Bug 22046.

_passes_required_checks takes the marc record data as parameter, but the refactoring done in bug 22046 results in the record id beeing passed instead.
Comment 1 Andreas Jonsson 2020-01-05 13:04:46 UTC
Created attachment 96825 [details] [review]
Bug 24348: Pass marc record to _passes_required_checks
Comment 2 Andreas Jonsson 2020-01-05 13:06:42 UTC
Test plan:

* Add record matching rule:

 Matching rule code: test
 Description: 001 and 003
 Match threshold: 1000
 Record type: Bibliografic record

 Match points:
    Search index: Control-number
    Score: 1000
    Tag: 001
    Subfields:
    Offset:
    Length:
    Normalization rule: none

 Required match checks:


    Source (incoming) record check field

    Tag: 003
    Subfields:
    Offset:
    Length:
    Normalization rule: none

    Target (database) record check field

    Tag: 003
    Subfields:
    Offset:
    Length:
    Normalization rule: none

* Note the match rule identity number.
* Stage a marc-file for import, for instance this one ftp://ftp.libris.kb.se/pub/export2/X/marc/X.20200104.marc

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/stage_file.pl --match 4 --file 'X.20200104.marc' --format ISO2709 --comment 'test'" kohadev

* Note the batch number and commit the file using the batch number:

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/commit_file.pl --batch-number 1" kohadev

* Again, stage the same marc-file  for import:

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/stage_file.pl --match 4 --file 'X.20200104.marc' --format ISO2709 --comment 'test'" kohadev

* Note the number of records matched.
Comment 3 Martin Renvoize (ashimema) 2020-01-27 19:01:16 UTC
Created attachment 97993 [details] [review]
Bug 24348: Pass marc record to _passes_required_checks

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2020-01-27 19:02:28 UTC
Works as expected, signing off.. it would be great to see an accompanying regression test though.
Comment 5 Jonathan Druart 2020-01-28 12:16:06 UTC
Created attachment 98021 [details] [review]
Bug 24348: Pass marc record to _passes_required_checks

Test plan:

* Add record matching rule:

 Matching rule code: test
 Description: 001 and 003
 Match threshold: 1000
 Record type: Bibliografic record

 Match points:
    Search index: Control-number
    Score: 1000
    Tag: 001
    Subfields:
    Offset:
    Length:
    Normalization rule: none

 Required match checks:

    Source (incoming) record check field

    Tag: 003
    Subfields:
    Offset:
    Length:
    Normalization rule: none

    Target (database) record check field

    Tag: 003
    Subfields:
    Offset:
    Length:
    Normalization rule: none

* Note the match rule identity number.
* Stage a marc-file for import, for instance this one ftp://ftp.libris.kb.se/pub/export2/X/marc/X.20200104.marc

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/stage_file.pl --match 4 --file 'X.20200104.marc' --format ISO2709 --comment 'test'" kohadev

* Note the batch number and commit the file using the batch number:

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/commit_file.pl --batch-number 1" kohadev

* Again, stage the same marc-file  for import:

sudo /usr/sbin/koha-shell -c "perl /home/vagrant/kohaclone/misc/stage_file.pl --match 4 --file 'X.20200104.marc' --format ISO2709 --comment 'test'" kohadev

* Note the number of records matched.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
I did not test, trusting author and SO. Changes make perfect sense to
me.
Comment 6 Martin Renvoize (ashimema) 2020-01-28 15:06:41 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 7 Joy Nelson 2020-02-10 22:44:52 UTC
Pushed to 19.11.x branch for 19.11.03
Comment 8 Lucas Gass (lukeg) 2020-02-14 18:49:02 UTC
backported to 19.05.x for 19.05.08
Comment 9 Hayley Pelham 2020-02-17 20:28:45 UTC
Dependency not in 18.11.x series, not backporting.