<commit_before>
require 'firebase'

base_uri = 'https://rigadevdays2017.firebaseio.com/'
firebase = Firebase::Client.new(base_uri)


SCHEDULER.every '5m', :first_in => 0 do |job|

  sessions      = firebase.get('sessions').body
  speakers      = firebase.get('speakers').body
  feedback      = firebase.get('userFeedbacks').body

  voting_data   = Hash[
    sessions.select { |session_id, session_data| session_data.key?('speakers') }.collect do |session_id, session_data|
      speaker     = speakers[session_data['speakers'].first]
      [
        session_id,
        {
            title: session_data['title'],
            avatar: "https://rigadevdays.lv/#{speaker['photoUrl']}",
            author: speaker['name'],
            speakerPoints: 0.0,
            speakerVotes: 0.0,
            contentPoints: 0.0,
            contentVotes: 0.0,
            rate: 0.0
        }
      ]
    end
  ]

  feedback.each do |user_id, session_feedback|
    session_feedback.each do |session_id, ratings|
      session_data = voting_data[session_id.to_s]
      if ratings.key?('qualityOfContent') && ['qualityOfContent']
        session_data[:contentPoints] += ratings['qualityOfContent'].to_i
        session_data[:contentVotes] += 1
      end
      if ratings.key?('speakerPerformance') && ratings['speakerPerformance']
        session_data[:speakerPoints] += ratings['speakerPerformance'].to_i
        session_data[:speakerVotes] += 1
      end
      session_data[:totalVotes] = session_data[:speakerVotes] + session_data[:contentVotes]
      session_data[:rate] = session_data[:totalVotes] > 0 ? (session_data[:speakerPoints] + session_data[:contentPoints]) / session_data[:totalVotes] : 0.0
    end
  end

  votes = voting_data
              .map { |session_id, session_data| session_data }
              .select { |session_data| session_data[:rate] > 0 }
              .select { |session_data| session_data[:totalVotes] > 0 }
              .sort { |s1, s2| s2[:rate] <=> s1[:rate] }
              .take(6)

  votes.each { |session| session[:rate] = "%.2f" % session[:rate] }
<commit_msg>changed voting limit<commit_after>
require 'firebase'

base_uri = 'https://rigadevdays2017.firebaseio.com/'
firebase = Firebase::Client.new(base_uri)


SCHEDULER.every '5m', :first_in => 0 do |job|

  sessions      = firebase.get('sessions').body
  speakers      = firebase.get('speakers').body
  feedback      = firebase.get('userFeedbacks').body

  voting_data   = Hash[
    sessions.select { |session_id, session_data| session_data.key?('speakers') }.collect do |session_id, session_data|
      speaker     = speakers[session_data['speakers'].first]
      [
        session_id,
        {
            title: session_data['title'],
            avatar: "https://rigadevdays.lv/#{speaker['photoUrl']}",
            author: speaker['name'],
            speakerPoints: 0.0,
            speakerVotes: 0.0,
            contentPoints: 0.0,
            contentVotes: 0.0,
            rate: 0.0
        }
      ]
    end
  ]

  feedback.each do |user_id, session_feedback|
    session_feedback.each do |session_id, ratings|
      session_data = voting_data[session_id.to_s]
      if ratings.key?('qualityOfContent') && ['qualityOfContent']
        session_data[:contentPoints] += ratings['qualityOfContent'].to_i
        session_data[:contentVotes] += 1
      end
      if ratings.key?('speakerPerformance') && ratings['speakerPerformance']
        session_data[:speakerPoints] += ratings['speakerPerformance'].to_i
        session_data[:speakerVotes] += 1
      end
      session_data[:totalVotes] = session_data[:speakerVotes] + session_data[:contentVotes]
      session_data[:rate] = session_data[:totalVotes] > 0 ? (session_data[:speakerPoints] + session_data[:contentPoints]) / session_data[:totalVotes] : 0.0
    end
  end

  votes = voting_data
              .map { |session_id, session_data| session_data }
              .select { |session_data| session_data[:rate] > 0 }
              .select { |session_data| session_data[:totalVotes] > 10 }
              .sort { |s1, s2| s2[:rate] <=> s1[:rate] }
              .take(6)

  votes.each { |session| session[:rate] = "%.2f" % session[:rate] }

{'fraction_non_alphanumeric': 0.13642891335567256, 'fraction_numerical': 0.014121589277166108, 'mean_word_length': 2.8304307974335474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 4, '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': '1722704', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1322, 'n_words': 226}