app/jobs/send_db_diff_job.rb
# Notify uniq team managers for each editor/found found while looping on AppParameter
# to extract the DB-diff data.
# This may deliver more than 1 email notification for each edit (depending on total
# TeamManagers for each swimmer).
#
# === Params:
#
# - team_managers_data: Hash having structure:
#     {
#       TM.user1.id => {
#           tm_user: TM.user1,
#           users: [editor_user1, editor_user2, ...],
#           urls:  [req_url1_1, req_url1_2, ..., req_url2_1, ...],
#           description: remote_edit_type_description
#       },
#
#       TM.user2.id => { ... } #, ...
#     }
#
Notify uniq team managers for each editor/found found while looping on AppParameter
to extract the DB-diff data.
This may deliver more than 1 email notification for each edit (depending on total
TeamManagers for each swimmer).






Notify uniq team managers for each editor / found found while looping on AppParameter to extract the DB - diff data . This may deliver more than 1 email notification for each edit ( depending on total TeamManagers for each swimmer ) .
def prepare_and_deliver_update_notifications( team_managers_data )
    team_managers_data.each do |tm_id, tm_data|
      dest_user = tm_data[:tm_user]
      editors   = tm_data[:users].reject { |user| user.id == dest_user.id }
                                 .map { |user| user.swimmer.get_full_name }
                                 .uniq
      base_uris = tm_data[:urls].uniq
                                .map { |s| "<li><a href=\"#{ s }\">#{ s.split(/\/meeting_/).last }</a></li>" }
                                .join("\r\n")
      if editors.size > 0
        logger.info( "Preparing notification for '#{ dest_user.email }'..." )
        subject   = I18n.t('newsletter_mailer.remote_edit.title', what: tm_data[:description])
        title     = I18n.t('newsletter_mailer.remote_edit.subject', what: tm_data[:description].downcase.camelcase)
        contents  = I18n.t(
          'newsletter_mailer.remote_edit.contents',
          user_names: editors.join(', '),
          base_uris:  base_uris
        )
        NewsletterMailer.custom_mail( dest_user, subject, title, contents ).deliver
      end
    end
  end
def prepare_and_deliver_update_notifications ( team_managers_data ) team_managers_data . each do | tm_id , tm_data | dest_user = tm_data [ :tm_user ] editors = tm_data [ :users ] . reject { | user | user . id == dest_user . id } . map { | user | user . swimmer . get_full_name } . uniq base_uris = tm_data [ :urls ] . uniq . map { | s | "<li><a href=\"#{ s }\">#{ s.split(/\/meeting_/).last }</a></li>" } . join ( "\r\n" ) if editors . size > 0 logger . info ( "Preparing notification for '#{ dest_user.email }'..." ) subject = I18n . t ( 'newsletter_mailer.remote_edit.title' , what : tm_data [ :description ] ) title = I18n . t ( 'newsletter_mailer.remote_edit.subject' , what : tm_data [ :description ] . downcase . camelcase ) contents = I18n . t ( 'newsletter_mailer.remote_edit.contents' , user_names : editors . join ( ', ' ) , base_uris : base_uris ) NewsletterMailer . custom_mail ( dest_user , subject , title , contents ) . deliver end end end
Notify uniq team managers for each editor/found found while looping on AppParameter
to extract the DB-diff data.
Notify uniq team managers for each editor / found found while looping on AppParameter to extract the DB - diff data .
# DEBUG # puts "\r\n\r\n- team_managers_data:" # pp team_managers_data.inspect # Notify uniq team managers for each editor_user: # Filter self from list of editors: # If there are editors left, compile the newsletter mailer for the notification:
team_managers_data
<not_specific>