app/workers/delete_old_bets_worker.rb
# All expired bets older than this, or all disabled bets last
# updated longer ago than this, are deleted
All expired bets older than this, or all disabled bets last
updated longer ago than this, are deleted
All expired bets older than this or all disabled bets last updated longer ago than this are deleted
def perform
    queries = old_expired_bets.map(&:query_id).uniq + old_disabled_bets.map(&:query_id).uniq
    old_expired_bets.delete_all
    old_disabled_bets.delete_all
    queries.each do |qid|
      q = Query.find(qid)
      SearchApiSaver.new(q).destroy(action: :delete) if q.bets.empty?
    end
  end
def perform queries = old_expired_bets . map ( & :query_id ) . uniq + old_disabled_bets . map ( & :query_id ) . uniq old_expired_bets . delete_all old_disabled_bets . delete_all queries . each do | qid | q = Query . find ( qid ) SearchApiSaver . new ( q ) . destroy ( action : :delete ) if q . bets . empty? end end
All expired bets older than this, or all disabled bets last
updated longer ago than this, are deleted
All expired bets older than this or all disabled bets last updated longer ago than this are deleted
# remove empty queries from search-api to avoid cruft in the index