Commit ed1503eff6a94b745c1f11bf4cc223c906d56823
1 parent
f44412f0
Exists in
master
and in
1 other branch
add find ambiguous times task
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
lib/tasks/prune_db.rake
1 | 1 | namespace :prune_db do |
2 | 2 | |
3 | + desc "Finds ambiguous times due to daylight savings time" | |
4 | + task :find_ambiguous_times => :environment do | |
5 | + datetime_fields = { | |
6 | + :appearances => ['created_at', 'updated_at'], | |
7 | + :choices => ['created_at', 'updated_at'], | |
8 | + :clicks => ['created_at', 'updated_at'], | |
9 | + :densities => ['created_at', 'updated_at'], | |
10 | + :flags => ['created_at', 'updated_at'], | |
11 | + :prompts => ['created_at', 'updated_at'], | |
12 | + :skips => ['created_at', 'updated_at'], | |
13 | + :votes => ['created_at', 'updated_at'], | |
14 | + :visitors => ['created_at', 'updated_at'], | |
15 | + :users => ['created_at', 'updated_at'], | |
16 | + :questions => ['created_at', 'updated_at'], | |
17 | + :question_versions => ['created_at', 'updated_at'], | |
18 | + :delayed_jobs => ['created_at', 'updated_at', 'run_at', 'locked_at', 'failed_at'], | |
19 | + } | |
20 | + datetime_fields.each do |table, columns| | |
21 | + where = columns.map{|c| "((#{c} > '2010-11-07 00:59:59' AND #{c} < '2010-11-07 02:00:00') OR (#{c} > '2011-11-06 00:59:59' AND #{c} < '2011-11-06 02:00:00'))"}.join(" OR ") | |
22 | + rows = ActiveRecord::Base.connection.select_all( | |
23 | + "SELECT id, #{columns.join(", ")} FROM #{table} WHERE #{where}" | |
24 | + ) | |
25 | + puts rows.inspect if rows.length > 0 | |
26 | + end | |
27 | + end | |
28 | + | |
3 | 29 | desc "Converts all dates from PT to UTC" |
4 | 30 | task :convert_dates_to_utc => :environment do |
5 | 31 | time_spans = [ | ... | ... |