<commit_before># Schedule LeaderCheckInJob for leaders in each timezone.
class ScheduleLeaderCheckInsJob < ApplicationJob
  HACK_CLUB_TEAM_ID = 'T0266FRGM'.freeze
  CLUB_ACTIVE_STAGE_KEY = '5003'.freeze
  CLUB_PIPELINE_KEY = Rails.application.secrets.streak_club_pipeline_key
  LEADER_ACTIVE_STAGE_KEY = '5006'.freeze
  LEADER_PIPELINE_KEY = Rails.application.secrets.streak_leader_pipeline_key

  def perform
    pocs.each do |poc|
      trigger_time = time_offset(poc[:latitude], poc[:longitude])

      LeaderCheckInJob.set(wait_until: trigger_time).perform_later streak_key
    end
  end

  private

  def time_offset(lat, lng, day = 'friday', local_time = 17.hours)
    runtime_day = Date.parse(day)
    next_runtime = runtime_day + local_time
    Timezone.lookup(lat, lng).local_to_utc(next_runtime)
  rescue Timezone::Error::InvalidZone
    Rails.logger.warn "Timezone invalid, defaulting to PST"
    Timezone.fetch('America/Los_Angeles').local_to_utc(next_runtime)
  end

  def active_club_boxes
    @club_active_boxes ||= StreakClient::Box
                           .all_in_pipeline(CLUB_PIPELINE_KEY)
                           .select do |b|
      b[:stage_key] == CLUB_ACTIVE_STAGE_KEY
    end<commit_msg>Fix rubocop<commit_after># Schedule LeaderCheckInJob for leaders in each timezone.
class ScheduleLeaderCheckInsJob < ApplicationJob
  HACK_CLUB_TEAM_ID = 'T0266FRGM'.freeze
  CLUB_ACTIVE_STAGE_KEY = '5003'.freeze
  CLUB_PIPELINE_KEY = Rails.application.secrets.streak_club_pipeline_key
  LEADER_ACTIVE_STAGE_KEY = '5006'.freeze
  LEADER_PIPELINE_KEY = Rails.application.secrets.streak_leader_pipeline_key

  def perform
    pocs.each do |poc|
      trigger_time = time_offset(poc[:latitude], poc[:longitude])

      LeaderCheckInJob.set(wait_until: trigger_time).perform_later streak_key
    end
  end

  private

  def time_offset(lat, lng, day = 'friday', local_time = 17.hours)
    runtime_day = Date.parse(day)
    next_runtime = runtime_day + local_time
    Timezone.lookup(lat, lng).local_to_utc(next_runtime)
  rescue Timezone::Error::InvalidZone
    Rails.logger.warn 'Timezone invalid, defaulting to PST'
    Timezone.fetch('America/Los_Angeles').local_to_utc(next_runtime)
  end

  def active_club_boxes
    @club_active_boxes ||= StreakClient::Box
                           .all_in_pipeline(CLUB_PIPELINE_KEY)
                           .select do |b|
      b[:stage_key] == CLUB_ACTIVE_STAGE_KEY
    end
{'fraction_non_alphanumeric': 0.0838126540673788, 'fraction_numerical': 0.011503697617091208, 'mean_word_length': 3.9693877551020407, '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': '119598', 'n_tokens_mistral': 870, 'n_tokens_neox': 855, 'n_words': 140}