Skip to main content
edited tags
Link
Phrancis
  • 20.4k
  • 6
  • 68
  • 154
added 290 characters in body
Source Link
Ryan.lay
  • 264
  • 1
  • 8
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(idrecord)
     recordupdated_record = RecordBaseAmountService.build.call(record, record.subrecord)  
     recordupdated_record.save
  end

end

class MonthlyTaskService

    def call
        record_pool = MonthlyRecordWorker.pool(size: 10)
        
        Record.all.each do |i|
           record_pool.async.update_record(i.id)
        end
    end

end


#lib/tasks/monthly.rake

namespace :monthly do
    desc "Cron tasks"
    task :audit_records => :environment do
        MonthlyTaskService.build.call
    end
end


      
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(id)
     record = RecordBaseAmountService.build.call(record, subrecord)  
     record.save
  end

end

class MonthlyTaskService

    def call
        record_pool = MonthlyRecordWorker.pool(size: 10)

        Record.all.each do |i|
           record_pool.async.update_record(i.id)
        end
    end

end


#lib/tasks/monthly.rake

namespace :monthly do
    desc "Cron tasks"
    task :audit_records => :environment do
        MonthlyTaskService.build.call
    end
end


      
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(record)
     updated_record = RecordBaseAmountService.build.call(record, record.subrecord)  
     updated_record.save
  end

end

class MonthlyTaskService

    def call
        record_pool = MonthlyRecordWorker.pool(size: 10)
        
        Record.all.each do |i|
           record_pool.async.update_record(i)
        end
    end

end


#lib/tasks/monthly.rake

namespace :monthly do
    desc "Cron tasks"
    task :audit_records => :environment do
        MonthlyTaskService.build.call
    end
end


      
added 290 characters in body
Source Link
Ryan.lay
  • 264
  • 1
  • 8
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(id)
     record = RecordBaseAmountService.build.call(record, subrecord)  
     record.save
  end

end

class MonthlyTaskService

    def call
        record_pool = MonthlyRecordWorker.pool(size: 10)

        Record.all.each do |i|
           record_pool.async.update_record(i.id)
        end
    end

end


#lib/tasks/monthly.rake

namespace :monthly do
    desc "Cron tasks"
    task :audit_records => :environment do
        MonthlyTaskService.build.call
    end
end


      
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(id)
     record = RecordBaseAmountService.build.call(record, subrecord)  
     record.save
  end

end

record_pool = MonthlyRecordWorker.pool(size: 10)

Record.all.each do |i|
  record_pool.async.update_record(i.id)
end


      
require "celluloid"

class MonthlyRecordWorker
  include Celluloid

  def update_record(id)
     record = RecordBaseAmountService.build.call(record, subrecord)  
     record.save
  end

end

class MonthlyTaskService

    def call
        record_pool = MonthlyRecordWorker.pool(size: 10)

        Record.all.each do |i|
           record_pool.async.update_record(i.id)
        end
    end

end


#lib/tasks/monthly.rake

namespace :monthly do
    desc "Cron tasks"
    task :audit_records => :environment do
        MonthlyTaskService.build.call
    end
end


      
added 2014 characters in body
Source Link
Ryan.lay
  • 264
  • 1
  • 8
Loading
added 85 characters in body; edited title
Source Link
Ryan.lay
  • 264
  • 1
  • 8
Loading
Post Reopened by syb0rg, Mast, Vogel612, Mathieu Guindon
Edited pseudocode
Source Link
Ryan.lay
  • 264
  • 1
  • 8
Loading
Post Closed as "Not suitable for this site" by syb0rg, BCdotWEB, 200_success
Source Link
Ryan.lay
  • 264
  • 1
  • 8
Loading