Checking if TS delayed delta job is finished

10 views
Skip to first unread message

Andrea S.

unread,
Oct 1, 2012, 4:23:12 PM10/1/12
to thinkin...@googlegroups.com
I was wondering whether there is an easy way to check that a TS delayed delta job has finished? I have a scenario in which I need to run a new search in an after_save callback and of course I'd like to see the changes to the delta index reflected in the search results.

Here are some details of my example:

I have a model called Feature which has many annotations (Annotation model). The index looks like this:

define_index do

   indexes annotations.value, :as => :annotations

  # other indexes

  has annotations.status(:name), :as => :annotation_status 

  where "statuses.name = 'current' AND (statuses_annotations.name = 'current' OR statuses_annotations.name IS NULL)"

  set_property :delta => :delayed

end

An annotation can change it's value or it can become outdated (status change), in which case I update the delta attribute of the associated feature in an Annotation model callback. Setting the delta attribute to true spins off a delayed_job task to update the delta index. In a separate callback I'd like to perform a new search against the updated delta index, but I noticed that the search never reflects the current state of the index. This is no doubt because the delta jobs are not finished yet. 

What would be the best strategy to deal with this scenario?

Thanks!

Andrea

Reply all
Reply to author
Forward
0 new messages