feedcast / scott

:briefcase: The Podcast Regional Manager
https://api.feedcast.io
Apache License 2.0
22 stars 5 forks source link

Move indexer attributes to a query #12

Open marceloboeira opened 7 years ago

marceloboeira commented 7 years ago

Right now the indexer "query" is done on every request... it would be better to have it as a query...

Instead of

Episode.all.each do |episode|

if episde....

end
Episode.not_indexed.each do |episode|
...
end

where Episode.not_indexed is:

class Episode
  scope :not_indexed -> { where(indexed: nil).or(....) }
end

That improves the performance because it does not fetch all episodes from mongo to ruby's memory so it can run against the if-else.

(Add a mongo-index to updated_at && indexed_at so it can run faster)

marceloboeira commented 7 years ago

related to #13