<commit_before>def move_expired_priority_time_events_to_main_event_queue
  #Find events that need to be moved *now*
  expired_events = $redis_cron.zrangebyscore REDIS_FUTURE_PRIORITY_QUEUE_KEY, 0, Time.now.to_i
  $redis_cron.zremrangebyscore REDIS_FUTURE_PRIORITY_QUEUE_KEY, 0, Time.now.to_i

  $redis_cron.pipelined do
    expired_events.each do |expired_event|
      $redis_cron.lpush REDIS_QUEUE_KEY, expired_event
    end
  end

  return expired_events
end

def schedule event:, time:
  stringized_event = event.to_json
  $redis_cron.zadd REDIS_FUTURE_PRIORITY_QUEUE_KEY, time.to_i, stringized_event
end
<commit_msg>WIP: Scheduling of actions working. A removed quest can still trigger via a scheduled event; this is an issue if the quest is added twice. Also, two servers will both assume cron role which could cause issues in certain cases.<commit_after>def move_expired_priority_time_events_to_main_event_queue
  #Find events that need to be moved *now*
  expired_events = $redis_cron.zrangebyscore REDIS_FUTURE_PRIORITY_QUEUE_KEY, 0, Time.now.to_i
  $redis_cron.zremrangebyscore REDIS_FUTURE_PRIORITY_QUEUE_KEY, 0, Time.now.to_i

  $redis_cron.pipelined do
    expired_events.each do |expired_event|
      $redis_cron.lpush REDIS_QUEUE_KEY, expired_event
    end
  end

  return expired_events
end

def schedule(event:, time:)
  stringized_event = event.to_json
  $redis_cron.zadd REDIS_FUTURE_PRIORITY_QUEUE_KEY, time.to_i, stringized_event
end

{'fraction_non_alphanumeric': 0.05639614855570839, 'fraction_numerical': 0.002751031636863824, 'mean_word_length': 5.554054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5920866', 'n_tokens_mistral': 567, 'n_tokens_neox': 541, 'n_words': 124}