我在某些JavaScript变量的视图中使用了此代码。任何想法,我可以使它更有效率?查看效率不高的代码
<% @sources.each_with_index do |source, index| %>
(<%= index %>, 1, <%= Entry.includes(:main_entries).where("classification_id =? and category_id =? and source_id =?", 1, 1, source.id).count %>)
(<%= index %>, 2, <%= Entry.includes(:main_entries).where("classification_id =? and category_id =? and source_id =?", 1, 2, source.id).count %>)
<% end %>