<commit_before>module Frontend
  class ReleaseAnnouncementProvider
    def self.find_by(filter_params = {})
      release_announcement_hashes = rummager_api.release_announcements(filter_params)
      build_collection(release_announcement_hashes)
    end

  private
    def self.build_collection(release_announcement_hashes)
      Array(release_announcement_hashes).map { | release_announcement_hash | Frontend::ReleaseAnnouncement.new(release_announcement_hash) }
    end

    def self.rummager_api
      Frontend::ReleaseAnnouncementRummagerStub
    end
  end

  class ReleaseAnnouncementRummagerStub
    RELEASE_ANNOUNCEMENTS = [
      {
        "title" => '2055 beard lengths',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2055-05-01 12:00:00"),
        "release_date_text" => 'May - June 2055',
        "organisations" => [ { "name" => "Ministry of beards", "slug" => "ministry-of-breards" } ]
      },
      {
        "title" => 'Womble population in Wimbledon Common 2063',
        "document_type" => 'Statistics',
        "release_date" => Time.zone.parse("2063-02-15 12:45:00"),
        "release_date_text" => nil,
        "organisations" => [ { "name" => "Wombat population regulation authority", "slug" => "wombat-population-regulation-authority" } ]
      }
    ]

    def self.release_announcements(search_params = {})
      filtered_announcements = RELEASE_ANNOUNCEMENTS.dup
      if search_params[:keywords].present?
        filtered_announcements.select! {|announcement| announcement['title'].include? search_params[:keywords] }
      end
      if search_params[:from_date].present?
        filtered_announcements.select! {|announcement| announcement['release_date'].to_date >= search_params[:from_date] }
      end
      if search_params[:to_date].present?
        filtered_announcements.select! {|announcement| announcement['release_date'].to_date <= search_params[:to_date] }
      end
      filtered_announcements
    end
  end
end<commit_msg>use real examples in rummager stub<commit_after>module Frontend
  class ReleaseAnnouncementProvider
    def self.find_by(filter_params = {})
      release_announcement_hashes = rummager_api.release_announcements(filter_params)
      build_collection(release_announcement_hashes)
    end

  private
    def self.build_collection(release_announcement_hashes)
      Array(release_announcement_hashes).map { | release_announcement_hash | Frontend::ReleaseAnnouncement.new(release_announcement_hash) }
    end

    def self.rummager_api
      Frontend::ReleaseAnnouncementRummagerStub
    end
  end

  class ReleaseAnnouncementRummagerStub
    RELEASE_ANNOUNCEMENTS = [
      {
        "title" => 'Quarterly bus statistics - Q4 2013',
        "document_type" => 'Statistics',
        "release_date" => Time.zone.parse("2014-03-11 09:30:00"),
        "release_date_text" => nil,
        "organisations" => [ { "name" => "Department of Transport", "slug" => "department-for-transport" } ]
      },
      {
        "title" => 'Incidence of TB in Cattle, Great Britain - Data to December 2013',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2014-03-12 00:00:00"),
        "release_date_text" => "12 March 2014",
        "organisations" => [ { "name" => "Department for Environment, Food and Rural Affairs", "slug" => "department-for-environment-food-rural-affairs" } ]
      },
      {
        "title" => 'Building Price and Cost Indices - Quarterly Update March 2014',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2014-03-18 09:30:00"),
        "release_date_text" => nil,
        "organisations" => [ { "name" => "Department for Business, Innovation and Skills", "slug" => "department-for-business-innovation-skills" } ]
      },
      {
        "title" => 'UK Armed Forces Monthly Personnel Report - 1 February 2015',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2015-03-12 00:00:00"),
        "release_date_text" => "March - April 2015",
        "organisations" => [ { "name" => "Ministry of Defence", "slug" => "ministry-of-defence" } ]
      },
      {
        "title" => 'UK Armed Forces Monthly Personnel Report - 1 June 2015',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2015-07-16 00:00:00"),
        "release_date_text" => nil,
        "organisations" => [ { "name" => "Ministry of Defence", "slug" => "ministry-of-defence" } ]
      },
      {
        "title" => 'Hydrocarbon Oils Bulletin - November 2015',
        "document_type" => 'National Statistics',
        "release_date" => Time.zone.parse("2015-12-22 09:30:00"),
        "release_date_text" => "December 2015",
        "organisations" => [ { "name" => "Ministry of Defence", "slug" => "ministry-of-defence" } ]
      }
    ]

    def self.release_announcements(search_params = {})
      filtered_announcements = RELEASE_ANNOUNCEMENTS.dup
      if search_params[:keywords].present?
        filtered_announcements.select! {|announcement| announcement['title'].include? search_params[:keywords] }
      end
      if search_params[:from_date].present?
        filtered_announcements.select! {|announcement| announcement['release_date'].to_date >= search_params[:from_date] }
      end
      if search_params[:to_date].present?
        filtered_announcements.select! {|announcement| announcement['release_date'].to_date <= search_params[:to_date] }
      end
      filtered_announcements
    end
  end
end

{'fraction_non_alphanumeric': 0.12843542302856117, 'fraction_numerical': 0.029638943775821807, 'mean_word_length': 3.3808025177025964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '6812228', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1705, 'n_words': 310}