diff options
Diffstat (limited to 'app')
10 files changed, 8 insertions, 245 deletions
diff --git a/app/mailers/emails/in_product_marketing.rb b/app/mailers/emails/in_product_marketing.rb index 972c1da065a..92743dc1926 100644 --- a/app/mailers/emails/in_product_marketing.rb +++ b/app/mailers/emails/in_product_marketing.rb @@ -12,15 +12,6 @@ module Emails 'X-Mailgun-Tag' => 'marketing' }.freeze - def in_product_marketing_email(recipient_id, group_id, track, series) - group = Group.find(group_id) - user = User.find(recipient_id) - email = user.notification_email_for(group) - @message = Gitlab::Email::Message::InProductMarketing.for(track).new(group: group, user: user, series: series) - - mail_to(to: email, subject: @message.subject_line) - end - def build_ios_app_guide_email(recipient_email) @message = ::Gitlab::Email::Message::BuildIosAppGuide.new diff --git a/app/services/namespaces/in_product_marketing_emails_service.rb b/app/services/namespaces/in_product_marketing_emails_service.rb index 1ce7e4cae16..14e670126c6 100644 --- a/app/services/namespaces/in_product_marketing_emails_service.rb +++ b/app/services/namespaces/in_product_marketing_emails_service.rb @@ -44,108 +44,6 @@ module Namespaces interval_days = TRACKS.dig(track.to_sym, :interval_days) interval_days&.count || 0 end - - def self.send_for_all_tracks_and_intervals - TRACKS.each_key do |track| - TRACKS[track][:interval_days].each do |interval| - new(track, interval).execute - end - end - end - - def initialize(track, interval) - @track = track - @interval = interval - @sent_email_records = ::Users::InProductMarketingEmailRecords.new - end - - def execute - raise ArgumentError, "Track #{track} not defined" unless TRACKS.key?(track) - - groups_for_track.each_batch do |groups| - groups.each do |group| - send_email_for_group(group) - end - end - end - - private - - attr_reader :track, :interval, :sent_email_records - - def send_email(user, group) - NotificationService.new.in_product_marketing(user.id, group.id, track, series) - end - - def send_email_for_group(group) - users_for_group(group).each do |user| - if can_perform_action?(user, group) - send_email(user, group) - sent_email_records.add(user, track: track, series: series) - end - end - - sent_email_records.save! - end - - def groups_for_track - onboarding_progress_scope = Onboarding::Progress - .completed_actions_with_latest_in_range(completed_actions, range) - .incomplete_actions(incomplete_actions) - - # Filtering out sub-groups is a temporary fix to prevent calling - # `.root_ancestor` on groups that are not root groups. - # See https://gitlab.com/groups/gitlab-org/-/epics/5594 for more information. - Group - .top_most - .with_onboarding_progress - .merge(onboarding_progress_scope) - .merge(subscription_scope) - end - - def subscription_scope - {} - end - - # rubocop: disable CodeReuse/ActiveRecord - def users_for_group(group) - group.users - .where(email_opted_in: true) - .merge(Users::InProductMarketingEmail.without_track_and_series(track, series)) - end - # rubocop: enable CodeReuse/ActiveRecord - - def can_perform_action?(user, group) - case track - when :create, :verify - user.can?(:create_projects, group) - when :trial, :trial_short - user.can?(:start_trial, group) - when :team, :team_short - user.can?(:admin_group_member, group) - when :admin_verify - user.can?(:admin_group, group) - when :experience - true - end - end - - def completed_actions - TRACKS[track][:completed_actions] - end - - def range - date = (interval + 1).days.ago - date.beginning_of_day..date.end_of_day - end - - def incomplete_actions - TRACKS[track][:incomplete_actions] - end - - def series - TRACKS[track][:interval_days].index(interval) - end end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index d24f1ce399e..2832dfc340f 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -756,10 +756,6 @@ class NotificationService end end - def in_product_marketing(user_id, group_id, track, series) - mailer.in_product_marketing_email(user_id, group_id, track, series).deliver_later - end - def approve_mr(merge_request, current_user) approve_mr_email(merge_request, merge_request.target_project, current_user) end diff --git a/app/views/notify/in_product_marketing_email.html.haml b/app/views/notify/in_product_marketing_email.html.haml deleted file mode 100644 index a88d581c5de..00000000000 --- a/app/views/notify/in_product_marketing_email.html.haml +++ /dev/null @@ -1,51 +0,0 @@ -- if @message.series? - %tr{ style: "background-color: #ffffff;" } - %td{ style: "color: #424242; padding: 10px 30px; text-align: center; font-family: 'Source Sans Pro', helvetica, arial, sans-serif;font-size: 16px; line-height: 22px; border: 1px solid #dddddd" } - %p - = @message.progress.html_safe -%tr - %td{ bgcolor: "#ffffff", height: "auto", style: "max-width: 600px; width: 100%; text-align: center; height: 200px; padding: 25px 15px; mso-line-height-rule: exactly; min-height: 40px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif;", valign: "middle", width: "100%" } - = inline_image_link(@message.logo_path, { width: '150', style: 'width: 150px;' }) - %h1{ style: "font-size: 40px; line-height: 46x; color: #000000; padding: 20px 0 0 0; font-weight: normal;" } - = @message.title - %h2{ style: "font-size: 28px; line-height: 34px; color: #000000; padding: 0; font-weight: 400;" } - = @message.subtitle -%tr - %td{ style: "padding: 10px 20px 30px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; color:#000000; font-size: 18px; line-height: 24px;" } - %p{ style: "margin: 0 0 20px 0;" } - = @message.body_line1.html_safe - - @message.body_line2&.tap do |line| - %p{ style: "margin: 0 0 20px 0;" } - = line.html_safe -- if @message.cta_text - %tr - %td{ align: "center", style: "padding: 10px 20px 80px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif;" } - .cta_link.cta_link_primary= @message.cta_link -- else - %tr - %td{ style: "padding: 10px 20px 10px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; color:#000000; font-size: 16px; line-height: 20px;" } - %table{ border: "0", cellpadding: "0", cellspacing: "0", width: "100%", style: "width: 100%; min-width: 100%;" } - %tr - %td{ width: "50%", style: "width: 50%; min-width: 50%; color: #000000; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; font-size: 16px; line-height: 100%; padding-bottom: 16px; text-align: left;", align: "left" } - = @message.feedback_ratings(1) - %td{ width: "50%", style: "width: 50%; min-width: 50%; color: #000000; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; font-size: 16px; line-height: 100%; padding-bottom: 16px; text-align: right;", align: "right" } - = @message.feedback_ratings(5) - %tr - %td{ align: "center", style: "padding: 10px 1px 30px 1px;" } - %table{ align: "center", cellpadding: "5", cellspacing: "0", width: "100%", style: "width: 100%; min-width: 100%; border: 1px solid #dae0ea; border-radius: 0; min-width: 100%; text-align: center; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; font-size: 16px;" } - %tr - - (1..5).each do |rating| - %td{ height: "54", style: "border-left: 1px solid #dae0ea; padding-bottom: 0; width: 9% !important;", width: "9%" } - %a{ href: @message.feedback_link(rating), style: "color: #424242; display: block; text-decoration: none;" } - %span{ height: "54", style: "display: block; font-size: 18px; height: 22px; line-height: 22px; padding: 16px 0; width: 100%; text-decoration: none;" } - = rating - %tr - %td{ style: "padding: 10px 20px 30px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif; color:#000000; font-size: 18px; line-height: 24px;" } - %p{ style: "margin: 0 0 50px 0;" } - = @message.feedback_thanks -- if @message.invite_members? - %tr - %td{ align: "center", style: "padding: 0 20px 80px 20px; font-family: 'Source Sans Pro', helvetica, arial, sans-serif;" } - = @message.invite_text - %br - = @message.invite_link diff --git a/app/views/notify/in_product_marketing_email.text.erb b/app/views/notify/in_product_marketing_email.text.erb deleted file mode 100644 index 79a366eb1cc..00000000000 --- a/app/views/notify/in_product_marketing_email.text.erb +++ /dev/null @@ -1,36 +0,0 @@ -<%= @message.tagline %> - -<%= @message.title %> -<%= @message.subtitle %> - - -<%= @message.body_line1 %> - -<%= @message.body_line2 %> - -<% if @message.cta_text %> -<%= @message.cta_link %> - - - -<% else %> -<% (1..5).each do |rating| %> -<%= "#{rating} - #{@message.feedback_ratings(rating).upcase} - #{@message.feedback_link(rating)}" %> -<% end %> - - -<%= @message.feedback_thanks %> -<% end %> -<% if @message.invite_members? %> -<%= @message.invite_text %> -<%= @message.invite_link %> -<% end %> - - - - -<%= @message.footer_links %> - -<%= @message.address %> - -<%= @message.unsubscribe %> diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index fc73a3b0cbc..94b9acbc48b 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -579,15 +579,6 @@ :weight: 1 :idempotent: true :tags: [] -- :name: cronjob:namespaces_in_product_marketing_emails - :worker_name: Namespaces::InProductMarketingEmailsWorker - :feature_category: :experimentation_activation - :has_external_dependencies: false - :urgency: :low - :resource_boundary: :unknown - :weight: 1 - :idempotent: false - :tags: [] - :name: cronjob:namespaces_prune_aggregation_schedules :worker_name: Namespaces::PruneAggregationSchedulesWorker :feature_category: :source_code_management diff --git a/app/workers/background_migration/single_database_worker.rb b/app/workers/background_migration/single_database_worker.rb index 2f797a24468..56800c03bbb 100644 --- a/app/workers/background_migration/single_database_worker.rb +++ b/app/workers/background_migration/single_database_worker.rb @@ -45,7 +45,10 @@ module BackgroundMigration # lease on the class before giving up. See MR for more discussion. # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45298#note_434304956 def perform(class_name, arguments = [], lease_attempts = MAX_LEASE_ATTEMPTS) - unless Feature.enabled?(:execute_background_migrations, type: :ops) + should_skip = Feature.enabled?(:disallow_database_ddl_feature_flags, type: :ops) || + Feature.disabled?(:execute_background_migrations, type: :ops) + + if should_skip # Delay execution of background migrations self.class.perform_in(BACKGROUND_MIGRATIONS_DELAY, class_name, arguments, lease_attempts) diff --git a/app/workers/database/batched_background_migration/execution_worker.rb b/app/workers/database/batched_background_migration/execution_worker.rb index 1bdc829418a..75798f0ab73 100644 --- a/app/workers/database/batched_background_migration/execution_worker.rb +++ b/app/workers/database/batched_background_migration/execution_worker.rb @@ -64,6 +64,8 @@ module Database attr_accessor :database_name, :migration def enabled? + return false if Feature.enabled?(:disallow_database_ddl_feature_flags, type: :ops) + Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops) end diff --git a/app/workers/database/batched_background_migration/single_database_worker.rb b/app/workers/database/batched_background_migration/single_database_worker.rb index ebf63d34cbf..f73f8fd751b 100644 --- a/app/workers/database/batched_background_migration/single_database_worker.rb +++ b/app/workers/database/batched_background_migration/single_database_worker.rb @@ -27,6 +27,8 @@ module Database # :nocov: def enabled? + return false if Feature.enabled?(:disallow_database_ddl_feature_flags, type: :ops) + Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops) end diff --git a/app/workers/namespaces/in_product_marketing_emails_worker.rb b/app/workers/namespaces/in_product_marketing_emails_worker.rb deleted file mode 100644 index 470fba1227d..00000000000 --- a/app/workers/namespaces/in_product_marketing_emails_worker.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module Namespaces - class InProductMarketingEmailsWorker # rubocop:disable Scalability/IdempotentWorker - include ApplicationWorker - - data_consistency :always - - include CronjobQueue # rubocop:disable Scalability/CronWorkerContext - - feature_category :experimentation_activation - urgency :low - - def perform - return if paid_self_managed_instance? - return if setting_disabled? - - Namespaces::InProductMarketingEmailsService.send_for_all_tracks_and_intervals - end - - private - - def paid_self_managed_instance? - false - end - - def setting_disabled? - !Gitlab::CurrentSettings.in_product_marketing_emails_enabled - end - end -end - -Namespaces::InProductMarketingEmailsWorker.prepend_mod_with('Namespaces::InProductMarketingEmailsWorker') |