-
Notifications
You must be signed in to change notification settings - Fork 11
CV2-6701: Check newsletter: add limits #2419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
420b178
CV2-6701: check tipline_newsletter_enabled and limit
melsawy bd36521
CV2-6701: add settings to team
melsawy 765ef60
CV2-6701: add rake tasks to enable/disable, set subscribers limit
melsawy da338dd
Merge branch 'develop' into CV2-6701-check-newsletter-add-limits
melsawy 070888a
CV2-6701: fix tests
melsawy f2bb8ee
CV2-6701: change tipline_newsletter_enabled allowed values
melsawy 0d32d84
CV2-6701: add tests
melsawy 03f028f
CV2-6701: apply PR comments
melsawy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
58 changes: 58 additions & 0 deletions
58
lib/tasks/migrate/20260406120511_migrate_team_newsletter.rake
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| namespace :check do | ||
| namespace :migrate do | ||
| # bundle exec rails check:migrate:migrate_tipline_newsletter_action | ||
| desc 'Enable/disable tipline newsletter based on tipline platform' | ||
| task migrate_tipline_newsletter_action: :environment do | ||
| started = Time.now.to_i | ||
| smooch = BotUser.smooch_user | ||
| output = [] | ||
| TeamBotInstallation.where(user_id: smooch.id).find_each do |tbi| | ||
| print '.' | ||
| integrations = tbi.smooch_enabled_integrations | ||
| unless integrations.empty? | ||
| team = tbi.team | ||
| action = 2 | ||
| if integrations.count == 1 | ||
| action = !(integrations.keys == ['whatsapp']) | ||
| elsif !integrations.keys.include?('whatsapp') | ||
| action = 1 | ||
| else | ||
| platforms = TiplineSubscription.where(team_id: team.id).map(&:platform).uniq | ||
| if platforms.count == 1 | ||
| action = !(platforms == ['WhatsApp']) | ||
| end | ||
| end | ||
| # Use action.to_i as the return in lines 16 and 22 is a boolean | ||
| output << { team: team.slug, action: action.to_i } | ||
| team.set_tipline_newsletter_enabled = action.to_i | ||
| team.save! | ||
| end | ||
| end | ||
| puts "Workspace actions......\n" | ||
| pp output | ||
| minutes = ((Time.now.to_i - started) / 60).to_i | ||
| puts "[#{Time.now}] Done in #{minutes} minutes." | ||
| end | ||
| # bundle exec rails "check:migrate:set_tipline_newsletter_subscribers_limit[slug, limit]" | ||
| desc 'Set tipline newsletter subscribers limit, 0 means no limit' | ||
| task :set_tipline_newsletter_subscribers_limit, [:slug, :limit] => :environment do |_t, args| | ||
| raise "You should set team slug" if args[:slug].blank? | ||
| team = Team.where(slug: args[:slug]).first | ||
| unless team.nil? | ||
| limit = args[:limit].to_i == 0 ? nil : args[:limit].to_i | ||
| team.set_tipline_newsletter_subscribers_limit = limit | ||
| team.save! | ||
| end | ||
| end | ||
| # bundle exec rails "check:migrate:set_tipline_newsletter_action[slug, true/false]" | ||
| desc 'Enable/Disable tipline newsletter' | ||
| task :set_tipline_newsletter_action, [:slug, :action] => :environment do |_t, args| | ||
| raise "You should set team slug" if args[:slug].blank? | ||
| team = Team.where(slug: args[:slug]).first | ||
| unless team.nil? | ||
| team.set_tipline_newsletter_enabled = ActiveModel::Type::Boolean.new.cast(args[:action]) | ||
| team.save! | ||
| end | ||
| end | ||
| 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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.