lib/active_recall/models/deck.rb in active_recall-1.6.0 vs lib/active_recall/models/deck.rb in active_recall-1.6.1

- old
+ new

@@ -40,15 +40,17 @@ ActiveRecall::Item .find_by(deck: self, source_id: source.id, source_type: source.class.name) .destroy end + # OPTIMIZE: Attempt in active record, rather than array of Ruby records def review %i[untested failed expired].inject([]) do |words, s| words += items.send(s).order(random_order_function).map(&:source) end end + # OPTIMIZE: Use optimized #review and build only the record to be returned def next word = nil %i[untested failed expired].each do |category| word = items.send(category).order(random_order_function).limit(1).map(&:source).first break if word