Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2 from CloCkWeRX/avoid_loops
Browse files Browse the repository at this point in the history
Avoid looping behaviour (maitland, yass ATDIS feeds)
  • Loading branch information
henare committed Mar 21, 2016
2 parents ce20de6 + 054f971 commit d3fb8a7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/atdisplanningalertsfeed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ def self.save(url, options = {})
page = feed.applications(lodgement_date_start: options[:lodgement_date_start], lodgement_date_end: options[:lodgement_date_end])

# Save the first page
save_page(page)
pages_processed = []
pages_processed << page.pagination.current if save_page(page)

while page = page.next_page
save_page(page)
# Some ATDIS feeds incorrectly provide pagination
# and permit looping; so halt processing if we've already processed this page
unless pages_processed.index(page.pagination.current).nil?
puts "Page #{page.pagination.current} already processed; halting"
break
end

pages_processed << page.pagination.current if save_page(page)
end
end

Expand Down

0 comments on commit d3fb8a7

Please sign in to comment.