Last active
August 18, 2016 15:56
-
-
Save Lyoness/9ddd3603f8563032c4e49a2f4f6d8dd0 to your computer and use it in GitHub Desktop.
pgsql
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
ActiveRecord::Base.connection.execute('set statement_timeout to 300000') | |
sql = "SELECT distinct repository_id FROM builds where id BETWEEN 148806987 AND 152728050" | |
repository_ids = ActiveRecord::Base.connection.execute(sql).map{ |row| row['repository_id'].to_i } | |
affected_repositories = 0 | |
repository_ids.each do |id| | |
repo = Repository.find(id) | |
changed_builds = repo.builds.select {|b| b.created_at > '2016-08-09' && b.created_at < '2016-08-16' && b.previous_state == 'passed' && (b.state == 'failed' || b.state == 'errored') }.count | |
if changed_builds > 0 | |
affected_repositories += 1 | |
end | |
end | |
puts "total #{repository_ids.count}, affected #{affected_repositories}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment