eprints / eprints3.4

EPrints 3.4 core and releases
http://www.eprints.org/uk/index.php/eprints-3-4/
GNU Lesser General Public License v3.0
31 stars 28 forks source link

Possible efficiency improvement for Items screen #392

Closed jesusbagpuss closed 4 months ago

jesusbagpuss commented 4 months ago

I think these two lines of code: https://github.com/eprints/eprints3.4/blob/b5d35443a00fc16ddb465fdbe2dc8188c2145004/perl_lib/EPrints/Plugin/Screen/Items.pm#L202-L204 may result in two searches of the dataset being conducted, where only one is needed.

Both essentially end up calling $user->owned_eprint_list, although possibly with different params.

drn05r commented 4 months ago

There is a bit of a difference. has_eprints is does the user have any eprints at all whereas the list may be filtered to only include eprints of a certain status. Where there are no eprints at all the help box at the top will be displayed (unless Plugin/Screen/Items:help_no_items phrase is set) and no table (with filters above) will be displayed. However, if are some eprints but none matching the filter. Then the help box will be displayed (even if Plugin/Screen/Items:help_no_items is not set) and the table will display but just with a banner saying "No Items".

I think the only way this could be made slightly more efficent is to modify the $has_eprints logic as follows:

my $has_eprints = $list->count > 0 || $user->owned_eprints_list()->count > 0;