Last active
June 22, 2021 21:02
-
-
Save cesartalves/3b213c3be3478db269bf387396b709a7 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
corrected = [] | |
File.open('original.txt', 'r').each_line do |date| | |
new_date = Time.parse(date, '%Y-%m-%d %H%M%S') | |
if new_date.month == 6 && new_date.year == 2021 | |
corrected << new_date.next_month.beginning_of_month | |
next | |
end | |
while new_date.past? | |
next_date += 3.months | |
end | |
corrected << new_date | |
end | |
File.open('corrected.txt', 'w') do |f| | |
corrected.each { |date| f.puts date } | |
end |
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
subs = SolidusSubscriptions::Subscription.joins(:tags).where(tags: { name: 'legacy'}).distinct | |
subs.each do |sub| | |
new_date = sub.actionable_date | |
if new_date.month == 6 && new_date.year == 2021 | |
sub.actionable_date = new_date.next_month.beginning_of_month | |
sub.save! | |
next | |
end | |
while new_date.past? | |
new_date += 3.months | |
end | |
sub.actionable_date = new_date | |
sub.save! | |
end | |
end |
Line 1: we don't tag the subscription with
legacy
. maybeSolidusSubscriptions::Subscription.where.not(not: nil)
Line 12: the check for the month and year (ie June) needs to happen inside the loop. For any subscriptions, if the actionable date lands in June, we need to move the actionable date to July 1st.
Ok, no worries! We can do that :)
I don't get the SolidusSubscriptions::Subscription.where.not(not: nil)
though
ah!!! I meant notes
!
SolidusSubscriptions::Subscription.where.not(notes: nil)
.
The imported subscriptions will have the id in the notes field.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 1: we don't tag the subscription with
legacy
. maybeSolidusSubscriptions::Subscription.where.not(not: nil)
Line 12: the check for the month and year (ie June) needs to happen inside the loop. For any subscriptions, if the actionable date lands in June, we need to move the actionable date to July 1st.