<commit_before>class TasksManager
  def get_all_tasks_information(weeks) 
    return nil if weeks.nil? || weeks.empty? 

    all_tasks_information = Hash.new
    delayed_tasks = Array.new 
    aborted_tasks = Array.new 
    done_tasks = Array.new
    awaiting_tasks = Array.new

    all_tasks = collect_tasks_for_all_weeks(weeks) 

    all_tasks.each do |task|
      if task.status == SimpleTasksRuby::TaskType::DELAYED
        delayed_tasks.push(task) 
      elsif task.status == SimpleTasksRuby::TaskType::ABORTED
        aborted_tasks.push(task) 
      elsif task.status == SimpleTasksRuby::TaskType::DONE || task.status == SimpleTasksRuby::TaskType::DELAYED_DONE
        done_tasks.push(task) 
      elsif task.status == nil
        awaiting_tasks.push(task) 
      end
    end

    all_tasks_information[:delayed_tasks] = delayed_tasks
    all_tasks_information[:aborted_tasks] = aborted_tasks
    all_tasks_information[:done_tasks] = done_tasks
    all_tasks_information[:awaiting_tasks] = awaiting_tasks

    return all_tasks_information
  end

  def find_delayed_tasks_in_multiple_weeks(weeks) 
    tasks = collect_tasks_for_all_weeks(weeks)

    find_delayed_tasks(tasks)
  end

  def find_delayed_tasks(tasks)
    return nil if tasks.nil? || tasks.empty? 
 
    delayed_tasks = Array.new()

    tasks.each do |task|
      delayed_tasks.push(task) if task.status == SimpleTasksRuby::TaskType::DELAYED
    end

    return delayed_tasks
  end

  private 
    def collect_tasks_for_all_weeks(weeks)
      tasks = Array.new 

      weeks.each do |week|
        tasks += collect_tasks_for_week(week)
      end

      return tasks
    end
<commit_msg>Adds method to find tasks by status - more universal than current one to find only delayed tasks<commit_after>class TasksManager
  def get_all_tasks_information(weeks) 
    return nil if weeks.nil? || weeks.empty? 

    all_tasks_information = Hash.new
    delayed_tasks = Array.new 
    aborted_tasks = Array.new 
    done_tasks = Array.new
    awaiting_tasks = Array.new

    all_tasks = collect_tasks_for_all_weeks(weeks) 

    all_tasks.each do |task|
      if task.status == SimpleTasksRuby::TaskType::DELAYED
        delayed_tasks.push(task) 
      elsif task.status == SimpleTasksRuby::TaskType::ABORTED
        aborted_tasks.push(task) 
      elsif task.status == SimpleTasksRuby::TaskType::DONE || task.status == SimpleTasksRuby::TaskType::DELAYED_DONE
        done_tasks.push(task) 
      elsif task.status == nil
        awaiting_tasks.push(task) 
      end
    end

    all_tasks_information[:delayed_tasks] = delayed_tasks
    all_tasks_information[:aborted_tasks] = aborted_tasks
    all_tasks_information[:done_tasks] = done_tasks
    all_tasks_information[:awaiting_tasks] = awaiting_tasks

    return all_tasks_information
  end

  def find_delayed_tasks_in_multiple_weeks(weeks) 
    tasks = collect_tasks_for_all_weeks(weeks)

    find_delayed_tasks(tasks)
  end

  def find_tasks_by_status(tasks, task_status)
    return nil if tasks.nil? || tasks.empty?

    tasks.select { |task| task.status == task_status } 
  end
  
  # TODO: Obsolete - to be removed
  # TODO: When removed then collect_tasks_for_all_weeks method needs to be exposed as public
  def find_delayed_tasks(tasks)
    find_tasks_by_status(tasks, SimpleTasksRuby::TaskType::DELAYED)
  end

  private 
    def collect_tasks_for_all_weeks(weeks)
      tasks = Array.new 

      weeks.each do |week|
        tasks += collect_tasks_for_week(week)
      end

      return tasks
    end

{'fraction_non_alphanumeric': 0.07639875035501278, 'fraction_numerical': 0.0, 'mean_word_length': 3.486624203821656, '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': '6337627', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1099, 'n_words': 221}