Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.57 KB | None | 0 0
  1. namespace :reindex_doctor_locations do
  2.   desc "Reindex doctor profiles in batches"
  3.   task :execute, [:offset, :limit] => :environment do |task, args|
  4.  
  5.     Rails.application.eager_load!
  6.    
  7.     DoctorLocation.where(doctor_profile: DoctorProfile.left_joins(:doctor_source)
  8.                                                       .where("doctor_sources.url IS NULL OR (doctor_sources.url IS NOT NULL AND doctor_sources.url != 'npi')"))
  9.                   .order(:id)
  10.                   .offset(args.offset.to_i)
  11.                   .limit(args.limit.to_i).reindex!
  12.   end
  13.  
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement