2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-12 20:03:43 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
|
|
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
2018-03-25 17:30:42 +00:00
|
|
|
module MaintainTicketRecords
|
|
|
|
# a function for taking every ticket record with a card and creating a token
|
|
|
|
# if the event was in the last two weeks
|
|
|
|
def self.tokenize_cards_already_on_tickets
|
|
|
|
Qx.transaction do
|
2019-07-30 21:29:24 +00:00
|
|
|
event_ids = Event.where('end_datetime >= ?', Time.current - 2.weeks).pluck(:id)
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
t = Ticket.includes(:card).includes(:event).where('card_id IS NOT NULL and event_id IN (?)', event_ids)
|
2019-07-30 21:29:24 +00:00
|
|
|
t.each do |i|
|
|
|
|
token = InsertSourceToken.create_record(i.card, event: i.event)
|
2018-03-25 17:30:42 +00:00
|
|
|
i.source_token = token
|
|
|
|
i.save!
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|