Bug 17249

Summary: Koha::AuthorisedValues - Remove GetKohaAuthorisedValuesFromField
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: claire_gravely, kyle, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18748
Change sponsored?: --- Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 17094, 17248    
Bug Blocks: 15799, 17250, 19023    
Attachments: Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add classes MarcSubfieldStructure[s]
Bug 17249: Remove GetKohaAuthorisedValuesFromField - add tests
Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add search_by_marc_field
Bug 17249: Remove GetKohaAuthorisedValuesFromField - inventory
Bug 17249: Remove GetKohaAuthorisedValuesFromField - (follow-up) inventory
Bug 17249: Remove GetKohaAuthorisedValuesFromField
Bug 17249: GetKohaAuthorisedValuesFromField - rm GetAuthValCodeFromField
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add classes MarcSubfieldStructure[s]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - add tests
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add search_by_marc_field
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - inventory
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - (follow-up) inventory
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField
[SIGNED-OFF] Bug 17249: GetKohaAuthorisedValuesFromField - rm GetAuthValCodeFromField
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add classes MarcSubfieldStructure[s]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - add tests
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add search_by_marc_field
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - inventory
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - (follow-up) inventory
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField
[PASSED QA] Bug 17249: GetKohaAuthorisedValuesFromField - rm GetAuthValCodeFromField

Description Jonathan Druart 2016-09-05 14:15:33 UTC

    
Comment 1 Jonathan Druart 2016-09-05 15:20:38 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-09-05 15:20:41 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2016-09-05 15:20:44 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2016-09-05 15:20:47 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2016-09-05 15:20:50 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2016-09-05 15:20:53 UTC Comment hidden (obsolete)
Comment 7 Jonathan Druart 2016-09-05 15:20:56 UTC Comment hidden (obsolete)
Comment 8 Jonathan Druart 2016-09-08 19:49:08 UTC
(In reply to Jonathan Druart from comment #5)
> Created attachment 55180 [details] [review] [review]
> To make sure decrease this execution time to what it was before, this
> patch introduces a local to avoid the same query to be executed several
> times.

That does not mean anything...

Read:
To decrease this execution time to what it was before, this patch introduces a local cache not to execute the same query several times.
Comment 9 Claire Gravely 2016-09-09 10:39:14 UTC
patch does not apply

CONFLICT (content): Merge conflict in t/db_dependent/AuthorisedValues.t
Comment 10 Owen Leonard 2016-09-09 12:51:56 UTC
Created attachment 55428 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add classes MarcSubfieldStructure[s]

This patch adds the 2 Koha::Object based classes for the
marc_subfield_structure table

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 11 Owen Leonard 2016-09-09 12:52:06 UTC
Created attachment 55429 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - add tests

This patch adds a few tests to C4::Record::marcrecord2csv
The subroutine was not covered enough to validate that this patch set
won't add regressions.

Note that the patch set will fix an issue: If 2 subfields of a field are
linked to AVs and you want to display them in a CSV, they won't be
replaced with their descriptions.

Test plan:
Apply the patch, and make a copy of t/db_dependent/Record/marcrecord2csv.t
Checkout master and prove marcrecord2csv.t
Tests should fail
Checkout the branch with the whole patch set applied
The tests should pass

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 12 Owen Leonard 2016-09-09 12:52:15 UTC
Created attachment 55430 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add search_by_marc_field

This patch adds a new Koha::AuthorisedValues->search_by_marc_field
method.
It will permit to replace several subroutine from C4::Koha dealing with
authorised values.
It also uses this new methods to replace an occurrence of
GetKohaAuthorisedValuesFromField in C4::Record::marcrecord2csv

Test plan:
  prove t/db_dependent/AuthorisedValues.t
should return green

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 13 Owen Leonard 2016-09-09 12:52:21 UTC
Created attachment 55431 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - inventory

This patch deals with the inventory files calling
GetKohaAuthorisedValuesFromField.

Test plan:
  prove t/db_dependent/Items/GetItemsForInventory.t
should still return green

Use the inventory tool, on the result page the AV descriptions should
correctly replace the codes

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 14 Owen Leonard 2016-09-09 12:52:27 UTC
Created attachment 55432 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField - (follow-up) inventory

Before this patch set, the tests in
t/db_dependent/Items/GetItemsForInventory.t were executed in 4s. But
with the previous patch, it was in 45sec(!)
To make sure decrease this execution time to what it was before, this
patch introduces a local to avoid the same query to be executed several
times.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 15 Owen Leonard 2016-09-09 12:52:33 UTC
Created attachment 55433 [details] [review]
[SIGNED-OFF] Bug 17249: Remove GetKohaAuthorisedValuesFromField

Remove the subroutine, it's no longer in used.

Test plan:
  git grep GetKohaAuthorisedValuesFromField
should not return any occurrences.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 16 Owen Leonard 2016-09-09 12:52:41 UTC
Created attachment 55434 [details] [review]
[SIGNED-OFF] Bug 17249: GetKohaAuthorisedValuesFromField - rm GetAuthValCodeFromField

The subroutine GetAuthValCodeFromField was only used from
GetKohaAuthorisedValuesFromField.

Test plan:
  git grep GetAuthValCodeFromField
should not return any occurrences.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 17 Owen Leonard 2016-09-09 12:53:51 UTC
Everything tested correctly according to the test plans. The only issue I had was that GetItemsForInventory.t was still very slow. I don't know if that was a problem with the patch or a problem with my slow VM.
Comment 18 Martin Renvoize 2016-10-13 12:47:38 UTC
Created attachment 56380 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add classes MarcSubfieldStructure[s]

This patch adds the 2 Koha::Object based classes for the
marc_subfield_structure table

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Martin Renvoize 2016-10-13 12:47:52 UTC
Created attachment 56381 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - add tests

This patch adds a few tests to C4::Record::marcrecord2csv
The subroutine was not covered enough to validate that this patch set
won't add regressions.

Note that the patch set will fix an issue: If 2 subfields of a field are
linked to AVs and you want to display them in a CSV, they won't be
replaced with their descriptions.

Test plan:
Apply the patch, and make a copy of t/db_dependent/Record/marcrecord2csv.t
Checkout master and prove marcrecord2csv.t
Tests should fail
Checkout the branch with the whole patch set applied
The tests should pass

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Martin Renvoize 2016-10-13 12:47:56 UTC
Created attachment 56382 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - Add search_by_marc_field

This patch adds a new Koha::AuthorisedValues->search_by_marc_field
method.
It will permit to replace several subroutine from C4::Koha dealing with
authorised values.
It also uses this new methods to replace an occurrence of
GetKohaAuthorisedValuesFromField in C4::Record::marcrecord2csv

Test plan:
  prove t/db_dependent/AuthorisedValues.t
should return green

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize 2016-10-13 12:48:00 UTC
Created attachment 56383 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - inventory

This patch deals with the inventory files calling
GetKohaAuthorisedValuesFromField.

Test plan:
  prove t/db_dependent/Items/GetItemsForInventory.t
should still return green

Use the inventory tool, on the result page the AV descriptions should
correctly replace the codes

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Martin Renvoize 2016-10-13 12:48:03 UTC
Created attachment 56384 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField - (follow-up) inventory

Before this patch set, the tests in
t/db_dependent/Items/GetItemsForInventory.t were executed in 4s. But
with the previous patch, it was in 45sec(!)
To make sure decrease this execution time to what it was before, this
patch introduces a local to avoid the same query to be executed several
times.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Martin Renvoize 2016-10-13 12:48:07 UTC
Created attachment 56385 [details] [review]
[PASSED QA] Bug 17249: Remove GetKohaAuthorisedValuesFromField

Remove the subroutine, it's no longer in used.

Test plan:
  git grep GetKohaAuthorisedValuesFromField
should not return any occurrences.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Martin Renvoize 2016-10-13 12:48:12 UTC
Created attachment 56386 [details] [review]
[PASSED QA] Bug 17249: GetKohaAuthorisedValuesFromField - rm GetAuthValCodeFromField

The subroutine GetAuthValCodeFromField was only used from
GetKohaAuthorisedValuesFromField.

Test plan:
  git grep GetAuthValCodeFromField
should not return any occurrences.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 25 Martin Renvoize 2016-10-13 12:50:42 UTC
Good clear refactoring, much clearer code. Thanks Jonathan
Comment 26 Kyle M Hall 2016-10-21 15:20:33 UTC
Pushed to master for 16.11, thanks Jonathan!