Skip to content

Commit

Permalink
style: lower complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed May 6, 2022
1 parent 7e3605c commit 92efd4b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/jekyll-indico/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,16 @@ def get_parsed_results(base_url, indico_id, timeout: nil, **params)

# Run a block over each item in the downloaded results
def download_and_iterate(base_url, indico_id, limit: nil, **params, &block)
limit = nil if limit&.zero?
params[:limit] = limit if limit
params[:pretty] = 'no'

unless limit
if limit.nil? || limit.zero?
results = get_parsed_results(base_url, indico_id, **params)
results.each(&block)
return
end

0.step.each do |n|
results = get_parsed_results(base_url, indico_id, offset: n * limit, **params)
results = get_parsed_results(base_url, indico_id, offset: n * limit, limit: limit, **params)
results.each(&block)
break if results.length < limit
end
Expand Down

0 comments on commit 92efd4b

Please sign in to comment.