<commit_before>module PostHaste
  class MostViewed

    attr_reader :platform, :datetime, :title, :byline, :url

    def initialize(params={})
      params.each_pair do |k,v|
       instance_variable_set("@#{k}", v)
      end
    end

    def self.all(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/article,blog.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform)
    end

    def self.articles(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/article.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform)
    end

    def self.blogs(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/blog.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform)
    end

    def self.create(result={}, platform)
      result['content'].map{|r|
        self.new platform: platform,
                 datetime: DateTime.parse(result['updated']),
                 title: r['linkText'],
                 byline: r['byline'],
                 url: r['url']
        }
    end
  end
end
<commit_msg>added content type and rank<commit_after>module PostHaste
  class MostViewed

    attr_reader :platform, :datetime, :title, :byline, :url, :rank, :type

    def initialize(params={})
      params.each_pair do |k,v|
       instance_variable_set("@#{k}", v)
      end
    end

    def self.all(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/article,blog.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform, 'all')
    end

    def self.articles(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/article.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform, 'articles')
    end

    def self.blogs(platform='web', limit=25)
      url = "http://js.washingtonpost.com/most-viewed/#{platform}/blog.feed-#{limit}.json"
      create(HTTParty.get(url).parsed_response, platform, 'blogs')
    end

    def self.create(result={}, platform, type)
      result['content'].map!.with_index {|r,i|
        self.new platform: platform,
                 type: type,
                 datetime: DateTime.parse(result['updated']),
                 title: r['linkText'],
                 byline: r['byline'],
                 url: r['url'],
                 rank: i+1
        }
    end
  end
end

{'fraction_non_alphanumeric': 0.1568785197103781, 'fraction_numerical': 0.005229283990345938, 'mean_word_length': 2.695393759286776, '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': '6619763', 'n_tokens_mistral': 804, 'n_tokens_neox': 791, 'n_words': 137}