Let me explain the purpose for this job. I'm trying to remove orphan
hashtags that aren't being used anymore (destroyed posts) This job would
run once every month to clean out the database. I'm currently receiving
variable/method undefined for hashtaggable_ids. The code that I wrote is
below.


class RemoveHashtagOrphans < ActiveJob::Base
  queue_as :default

  def perform(hashtaggable_id)
    hashtags = SimpleHashtag::Hashtag.find(hashtaggables:
hashtaggable_id)
    orphans = hashtags.all.select {|h| h.hashtaggables.size == 0}
    orphans.map(&:destroy)
  end
end

#RemoveHashtagOrphans.new.perform(hashtaggable_id)
#RemoveHashtagOrphans.perform_at(1.month.from_now)


Original self.clean_orphan method below

def self.clean_orphans # From DB
  # TODO Make this method call a single SQL query
  orphans = self.all.select { |h| h.hashtaggables.size == 0 }
  orphans.map(&:destroy)
end


I need to take the clean_orphan method and convert it into a sidekiq
job.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/2d9d68b3eaeb329d4f36efa6034670f3%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to