-
-
Save camh96/e592a6ce623943f2532cbaee99081832 to your computer and use it in GitHub Desktop.
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
require 'date' | |
require 'active_support/time' | |
current_id = 100000000026499683 | |
starting_date = Date.new(2019,03,05) | |
times = [ | |
[9, 0, 60], | |
[11, 30, 30], | |
[13, 30, 30], | |
[15, 30, 30], | |
[17, 30, 30], | |
[19, 30, 30], | |
] | |
days = 14 | |
owner = 109228 | |
sql_statement = '' | |
rows = [] | |
sql_template = <<-SQL | |
SELECT * FROM SCHEDULED_EVENT ORDER BY ID DESC; | |
INSERT INTO SCHEDULED_EVENT (ID, | |
SCHEDULED_DATE, | |
DURATION, | |
STAFF_PERSON, | |
TYPE, | |
STATUS, | |
OWNER, | |
REQUESTED, | |
CREATE_DATE, | |
WEB_ID, | |
DIFF_HASH, | |
ROOM_USED, | |
PACKAGE_ITEM) | |
VALUES%s; | |
SQL | |
sql_row_template = "\n(%d, '%s', %d, 109206, 109231, 'Booked', %s, FALSE, NOW(), NULL, NULL, NULL, NULL)"; | |
(0..days).each do |d| | |
date = (starting_date + d.days) | |
times.each do |time| | |
(hour, minute, duration) = time | |
appointment_start_time = DateTime.new(date.year, date.month, date.day, hour, minute, 0) | |
rows.push sql_row_template % [current_id, appointment_start_time.to_s(:db), duration, owner] | |
current_id = current_id + 1 | |
end | |
end | |
puts sql_template % [rows.join(',')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment