Skip to content

Commit

Permalink
Warn if number of rows added doesn't match
Browse files Browse the repository at this point in the history
We seem to be having an odd bug where some of the people with multiple
memberships in the term only end up with a single row stored in the database.

To help debug this, warn if the number of rows for a person doesn't
match the number of memberships we just saved for them.
  • Loading branch information
tmtmtmtm committed Mar 7, 2017
1 parent b83b4d1 commit 71bf316
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ def scrape(h)
wanted = %i(start_date end_date area party term)
mems = current.map { |mem| data.merge(mem.keep_if { |k, v| wanted.include? k }) }
ScraperWiki.save_sqlite(%i(id term start_date), mems)
rows = ScraperWiki.select('COUNT(*) AS rows FROM data WHERE id = ?', data[:id]).first['rows']
warn "Row mismatch for #{data[:id]}: Have #{rows}, expected #{mems.count}" if rows != mems.count
end

0 comments on commit 71bf316

Please sign in to comment.