Sha256: 3888611bf044ad8c4617791a72c93d131be7bf4f952efb434e4fbb15bcd6203b
Contents?: true
Size: 1.6 KB
Versions: 12
Compression:
Stored size: 1.6 KB
Contents
namespace :db do desc 'test' task test: :environment do Iro::Datapoint.test end desc 'create calendar mdb' task create_calendar: :environment do year = 2023 d = "#{year}-01-01".to_date out = "" 368.times do if d.strftime('%Y').to_i == year+1 break end Iro::Date.create({ date: d.strftime('%Y-%m-%d') }) print '.' d = d + 1.day end end desc 'create calendar sql' task create_calendar_sql: :environment do year = 2023 d = "#{year}-01-01".to_date out = "" 368.times do if d.strftime('%Y').to_i == year+1 break end out = "#{out} ('#{d.strftime '%Y-%m-%d'}')," d = d + 1.day end out = out[0...out.length-1] out = " INSERT INTO dates (date) VALUES #{out} ;" File.write("/opt/tmp/#{year}_calendar.sql", out) `mv /opt/tmp/#{year}_calendar.sql doc/` end desc 'test datapoints' task create_test_datapoints: :environment do datapoint = Iro::Datapoint.create({ date: '2023-12-28', created_at: '2023-12-28 01:00:00', kind: 'some-type', value: 115, }) datapoint = Iro::Datapoint.create({ date: '2023-12-28', created_at: '2023-12-28 02:00:00', kind: 'some-type', value: 116, }) datapoint = Iro::Datapoint.create({ date: '2023-12-30', created_at: '2023-12-30 01:00:00', kind: 'some-type', value: 117, }) datapoint = Iro::Datapoint.create({ date: '2023-12-30', created_at: '2023-12-30 02:00:00', kind: 'some-type', value: 118, }) end end
Version data entries
12 entries across 12 versions & 1 rubygems