Skip to content

Instantly share code, notes, and snippets.

@amy-langley
Created March 7, 2019 01:09
Show Gist options
  • Save amy-langley/6f9a6df255365b41dea079e52c3026ba to your computer and use it in GitHub Desktop.
Save amy-langley/6f9a6df255365b41dea079e52c3026ba to your computer and use it in GitHub Desktop.
def get_page(workflow, last_id) workflow.extracts.where('id > ? and workflow_id = ?', last_id, workflow.id).order(id: :asc).take(10000); end
def eval_page(page) puts "#{page.count}\t#{page.last.id}\n"; [page.count, page.last&.id]; end
def page_thru(id)
wf = Workflow.find(id); last_id=0; count=10000;
count, last_id = eval_page(get_page(wf, last_id)) until count < 10000
end
def time_this() start=Time.now.utc; yield(); Time.now.utc-start; end
def time_one(wf) 11.times.map{ time_this { page_thru(wf.id) } }.sort[5]; end
Workflow.all.order(extracts_count: :asc).where('extracts_count > 0').take(100).each{ |wf| puts "#{wf.id}\t#{wf.extracts_count}\t\t#{time_one(wf)}\n" }.take(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment