<commit_before>require 'net/http'

module Meetup
  class MembersCount
    def self.total
      new.total
    end

    def initialize
      @key = ENV['MEETUP_KEY']
    end

    def members_count
      REDIS.get('meetup_members')
    end

    def get_meetup_members
      json = ::Net::HTTP.get(URI("http://api.meetup.com/2/groups?group_urlname=parisrb&format=json&key=#{@key}"))
      parisrb = JSON.parse(json).fetch('results').first
      REDIS.set('meetup_members', parisrb['members'])
      REDIS.expire('meetup_members', 24.hours)<commit_msg>quickfix: replaced meetup api v2 which is deprecated by HTML parsing fix #51 (#52)<commit_after>require 'net/http'

module Meetup
  class MembersCount
    def self.total
      new.total
    end

    def initialize
      @key = ENV['MEETUP_KEY']
    end

    def members_count
      REDIS.get('meetup_members')
    end

    def get_meetup_members
      doc = Nokogiri::HTML(open('https://www.meetup.com/parisrb/'))
      text = doc.css('a.groupHomeHeaderInfo-memberLink span').first.text
      count = text.split(' ').first.gsub(',', '').to_i
      REDIS.set('meetup_members', count)
      REDIS.expire('meetup_members', 24.hours)
      members_count
    end

    def get_meetup_members_old
      json = ::Net::HTTP.get(URI('http://api.meetup.com/2/groups?group_urlname=parisrb&format=json&key=#{@key}'))
      parisrb = JSON.parse(json).fetch('results').first
      REDIS.set('meetup_members', parisrb['members'])
      REDIS.expire('meetup_members', 24.hours)
{'fraction_non_alphanumeric': 0.14001327140013273, 'fraction_numerical': 0.008626410086264101, 'mean_word_length': 3.371014492753623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '3487184', 'n_tokens_mistral': 559, 'n_tokens_neox': 513, 'n_words': 87}