<commit_before>class Task::Notifications::DailyReminders < Mutations::Command

  DAYS_UNTIL_TASK = 1
  HOUR_OF_DAY     = 8

  optional do
    array :zones, class: String
  end


  def execute
    Rails.logger.info "--- Sending daily task reminders for tasks in timezones: #{zone_names}"

    tasks.each do |task|
      Task::Notifications::ReminderEmail.run task: task
    end
  end


  private


  def tasks
    @tasks ||= begin
      Task.
        not_completed.
        joins(:circle).
        joins(circle: :location).
        where(locations: {timezone: zone_names } ).
        where(due_date: zone_due_dates)
    end
  end

  def timezones
    @timezones ||= if zones.present?
      zones.map{ |tz| ActiveSupport::TimeZone[tz] }
    else
      ActiveSupport::TimeZone.all.select{ |tz| tz.now.hour == HOUR_OF_DAY }
    end
  end

  def zone_due_dates
    timezones.map{|tz| tz.today + DAYS_UNTIL_TASK }.uniq
  end

  def zone_names
    timezones.map{|tz| tz.tzinfo.identifier }
  end



end<commit_msg>more logging on daily reminder emails for verifying that tasks aren’t missed<commit_after>class Task::Notifications::DailyReminders < Mutations::Command

  DAYS_UNTIL_TASK = 1
  HOUR_OF_DAY     = 8

  optional do
    array :zones, class: String
  end


  def execute
    Rails.logger.info "--- Sending daily task reminders for tasks in timezones: #{zone_names}, tasks: #{tasks.map(&:id)}"
    tasks.each do |task|
      Task::Notifications::ReminderEmail.run task: task
    end
  end


  private


  def tasks
    @tasks ||= begin
      Task.
        not_completed.
        joins(:circle).
        joins(circle: :location).
        where(locations: {timezone: zone_names } ).
        where(due_date: zone_due_dates)
    end
  end


  def timezones
    @timezones ||= if zones.present?
      zones.map{ |tz| ActiveSupport::TimeZone[tz] }
    else
      ActiveSupport::TimeZone.all.select{ |tz| tz.now.hour == HOUR_OF_DAY }
    end
  end


  def zone_due_dates
    timezones.map{|tz| tz.today + DAYS_UNTIL_TASK }.uniq
  end


  def zone_names
    timezones.map{|tz| tz.tzinfo.identifier }.uniq
  end
end
{'fraction_non_alphanumeric': 0.10246679316888045, 'fraction_numerical': 0.0018975332068311196, 'mean_word_length': 2.7728085867620753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4037569', 'n_tokens_mistral': 764, 'n_tokens_neox': 714, 'n_words': 171}