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: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]

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.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to