C4::Biblio::GetHolds can be replaced with Koha::Biblio->holds->count
Created attachment 57492 [details] [review] Bug 17631: Koha::Biblio - Remove GetHolds C4::Biblio::GetHolds can be replaced with Koha::Biblio->holds->count Test plan: Create an order and place a hold on the biblio you have ordered. On the basket view, you should not be able to Cancel the order and/or delete the record Receive the order, on the parcel page you should get the same behavior.
Created attachment 57648 [details] [review] [SIGNED-OFF] Bug 17631: Koha::Biblio - Remove GetHolds C4::Biblio::GetHolds can be replaced with Koha::Biblio->holds->count Test plan: Create an order and place a hold on the biblio you have ordered. On the basket view, you should not be able to Cancel the order and/or delete the record Receive the order, on the parcel page you should get the same behavior. Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
As I read through this patch, I have an idea - maybe silly idea ;) But, does it make sense to you to have some method like Koha::Biblio->can_be_deleted? Probably useful on other places like catalogue/detail for example.
(In reply to Josef Moravec from comment #3) > As I read through this patch, I have an idea - maybe silly idea ;) > > But, does it make sense to you to have some method like > Koha::Biblio->can_be_deleted? > > Probably useful on other places like catalogue/detail for example. Yes and no, the can_be_deleted method will only check the permission of a user, I think we should only have only 1 method for this kind of simple permissions. But have a look at Koha::Virtualshelf and search for "sub can*".
Created attachment 57900 [details] [review] Bug 17631: Koha::Biblio - Remove GetHolds C4::Biblio::GetHolds can be replaced with Koha::Biblio->holds->count Test plan: Create an order and place a hold on the biblio you have ordered. On the basket view, you should not be able to Cancel the order and/or delete the record Receive the order, on the parcel page you should get the same behavior. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
C4 0.0187 Koha::Obj 0.1387 100 calls to GetHolds versus $biblio->holds->count (with one Biblios->find). C4 is 7 times faster.
(In reply to Marcel de Rooy from comment #6) > C4 0.0187 > Koha::Obj 0.1387 > > 100 calls to GetHolds versus $biblio->holds->count (with one Biblios->find). > C4 is 7 times faster. (10 holds on the same biblio record)
(In reply to Marcel de Rooy from comment #6) > C4 0.0187 > Koha::Obj 0.1387 > > 100 calls to GetHolds versus $biblio->holds->count (with one Biblios->find). > C4 is 7 times faster. Using an ORM is obviously heavier, this will be true for all the refactoring changes. However, you need to calculate everything in a context, ie. under plack and using memcached (keeping in mind we will try to cache more things).
(In reply to Jonathan Druart from comment #8) > Using an ORM is obviously heavier, this will be true for all the refactoring > changes. However, you need to calculate everything in a context, ie. under > plack and using memcached (keeping in mind we will try to cache more things). Sure. Just adding this for the record. Especially since you are not caching things here. (Which would probably useless in this specific case.)
Pushed to master for 17.05, thanks Jonathan!
This won't get ported back to 16.11.x as it is an enhancement.