forked from solidusio/solidus_subscriptions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Processor also sends reminders for upcoming subscriptions
- Loading branch information
Showing
7 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/jobs/solidus_subscriptions/subscription_reminder_job.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This job is responsible for sending reminders for upcoming subscription | ||
# fulfillments | ||
|
||
module SolidusSubscriptions | ||
class SubscriptionReminderJob < ActiveJob::Base | ||
queue_as Config.processing_queue | ||
|
||
# Process a collection of subscriptions | ||
# | ||
# @param subscription_ids [Array<Integer>] The ids of the | ||
# subscriptions to be processed together and reminded by the same email | ||
# | ||
# @return [SolidusSubscriptions::Subscription] The subscriptions that were sent reminders | ||
def perform(subscription_ids) | ||
return if subscription_ids.empty? | ||
|
||
subscriptions = SolidusSubscriptions::Subscription.where(id: subscription_ids) | ||
subscriptions.each do |subscription| | ||
subscription.remind! | ||
end | ||
|
||
subscriptions | ||
end | ||
end | ||
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20180618194253_add_reminded_flag_to_solidus_subscriptions_subscriptions.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddRemindedFlagToSolidusSubscriptionsSubscriptions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :solidus_subscriptions_subscriptions, :reminded, :boolean, null: false, default: false | ||
end | ||
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
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
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
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