Bug 38686

Summary: Add Koha::Items->filter_by_checked_out
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, tomascohen
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:
Circulation function:
Attachments: Bug 38686: Unit tests
Bug 38686: Add Koha::Items->filter_by_checked_out()
Bug 38686: Unit tests
Bug 38686: Add Koha::Items->filter_by_checked_out()

Description Tomás Cohen Arazi (tcohen) 2024-12-12 13:17:45 UTC
I wrote this method in an attempt to fix a behavior that wasn't exactly as I understood in the first place. So not sure I'll use it.

Putting it here in case it helps some other dev and deserves to be in the codebase.
Comment 1 Tomás Cohen Arazi (tcohen) 2024-12-12 13:22:12 UTC
Created attachment 175396 [details] [review]
Bug 38686: Unit tests
Comment 2 Tomás Cohen Arazi (tcohen) 2024-12-12 13:22:14 UTC
Created attachment 175398 [details] [review]
Bug 38686: Add Koha::Items->filter_by_checked_out()

This patch adds a method for filtering `Koha::Items` resultsets by
keeping only those items that currently checked out.

Usage:

```perl
if ( $biblio->items->filter_by_checked_out()->count ) {
    # do your stuff
}
```

To test:
1. Apply this patches
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass
3. Sign off :-D
Comment 3 Roman Dolny 2024-12-19 13:15:37 UTC
Created attachment 175763 [details] [review]
Bug 38686: Unit tests

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 4 Roman Dolny 2024-12-19 13:15:39 UTC
Created attachment 175764 [details] [review]
Bug 38686: Add Koha::Items->filter_by_checked_out()

This patch adds a method for filtering `Koha::Items` resultsets by
keeping only those items that currently checked out.

Usage:

```perl
if ( $biblio->items->filter_by_checked_out()->count ) {
    # do your stuff
}
```

To test:
1. Apply this patches
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass
3. Sign off :-D

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 5 Jonathan Druart 2025-01-16 15:02:43 UTC
Will be implemented on bug 37334.

*** This bug has been marked as a duplicate of bug 37334 ***
Comment 6 Tomás Cohen Arazi (tcohen) 2025-01-20 14:37:28 UTC
(In reply to Jonathan Druart from comment #5)
> Will be implemented on bug 37334.
> 
> *** This bug has been marked as a duplicate of bug 37334 ***

I liked my tests more :-P
Comment 7 Jonathan Druart 2025-01-20 15:13:52 UTC
Please add them there then. It's not pushed yet!