[Bug 30017] New: Should we prefer iterator.first over calling variable.count to reduce our DB hits
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Bug ID: 30017 Summary: Should we prefer iterator.first over calling variable.count to reduce our DB hits Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Templates Assignee: oleonard@myacpl.org Reporter: martin.renvoize@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org I noticed a pattern recently whereby we often call a count prior to iterating over the resultset: [% IF things.count %] <table> . . . [% FOREACH thing IN things %] <td>[% thing.whatever %]</td> [% END %] </table> [% END %] This introduces a count(*) DB call. We could instead use the first iteration of the iterator to setup the boilerplate and reduce our DB hits. [% FOREACH thing IN things %] [% IF thing.first %] <table> [% END %] <td>[% thing.whatever %]</td> [% IF thing.last %] </table> [% END %] [% END %] -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 --- Comment #1 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Doh.. it's wouldn'y be 'thing.first' and 'thing.last'.. it would be the special variables.. 'loop.first' and 'loop.last' in the above example. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=29859 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Should we prefer |Should we prefer |iterator.first over calling |`loop.first` and |variable.count to reduce |`loop.last` over calling |our DB hits |`variable.count` to reduce | |our DB hits -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=23991 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #2 from David Cook <dcook@prosentient.com.au> --- Sounds reasonable to me -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 --- Comment #3 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Sometimes we need to know if there is are least 1 row, to display a title for instance, or actions (check/uncheck all) at the top of the table. We will then end up with 2 patterns. Not a big deal, but worst noting it. Maybe better to have a TT var defined at the top of the template then reused all along? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|oleonard@myacpl.org |koha-bugs@lists.koha-commun | |ity.org -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org