-
-
Save mbie/72a1ff9a867a6c4dafd3e8bdb60a3b49 to your computer and use it in GitHub Desktop.
RRUG#16 Snippets
This file contains hidden or 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
| desc 'Rake task description' | |
| task :name_of_task do | |
| # Your code goes here | |
| end | |
| #> rake name_of_task |
This file contains hidden or 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
| namespace :mailchimp | |
| desc 'Import users from Mailchimp' | |
| task :import_users do | |
| Mailchimp::ImportUsers.call | |
| end | |
| end | |
| namespace :mailchimp | |
| desc 'Import users from Mailchimp' | |
| task :import_users do | |
| puts 'Importing users from Mailchimp' | |
| result = Mailchimp::ImportUsers.call | |
| puts "Successfully imported #{result} users!" | |
| end | |
| end |
This file contains hidden or 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
| namespace :cleanup | |
| desc 'Cleanup bad fees' | |
| task :fix_bad_fees do | |
| query = Cleanup::FixBadFees::Query.call | |
| progress_bar = ProgressBar.create( | |
| title: 'Fixing bad fees by adding a discount', | |
| total: query.count | |
| ) | |
| result = Cleanup::FixBadFees::Task.call(query: query) do | |
| progress_bar.increment | |
| end | |
| puts "Successfully fixed #{result} fees!" | |
| end | |
| end | |
| module Cleanup | |
| module FixBadFees | |
| class Task | |
| def self.call(*args, &block) | |
| new.self(*args, &block) | |
| end | |
| def call(query:) | |
| query.find_each do | |
| # Fix bad fees | |
| yield if block_given? | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment