Created
March 7, 2019 01:09
-
-
Save amy-langley/6f9a6df255365b41dea079e52c3026ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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