<commit_before>class CourseUserAggregateExport
  include Analytics::Export

  rows_by :users

  set_schema :username => :username,
             :total_pageviews => :pageviews,
             :total_logins => :logins,
             :total_predictor_events => :predictor_events,
             :total_predictor_sessions => :predictor_sessions

  def initialize(loaded_data)
    @user_predictor_event_counts = loaded_data[:predictor_events].inject(Hash.new(0)) do |hash, predictor_event|
      hash[predictor_event.user_id] += 1
      hash
    end
    @user_pageviews = loaded_data[:user_pageviews].inject(Hash.new(0)) do |hash, pageview|
      # CourseUserPageview must have `scope_by :pages` for this to work w/ mongoid > 4.0.0
      hash[pageview.user_id] = pageview.raw_attributes["pages"]["_all"]["all_time"]
      hash
    end
    @user_logins = loaded_data[:user_logins].inject(Hash.new(0)) do |hash, login|
      hash[login.user_id] = login["all_time"]["count"]
      hash
    end
    @user_predictor_sessions = loaded_data[:user_predictor_pageviews].inject(Hash.new(0)) do |hash, predictor_pageview|
      hash[predictor_pageview.user_id] = predictor_pageview["all_time"]
      hash
    end
    super
  end

  def pageviews(user, i)
    @user_pageviews[user.id]
  end<commit_msg>update the comment<commit_after>class CourseUserAggregateExport
  include Analytics::Export

  rows_by :users

  set_schema :username => :username,
             :total_pageviews => :pageviews,
             :total_logins => :logins,
             :total_predictor_events => :predictor_events,
             :total_predictor_sessions => :predictor_sessions

  def initialize(loaded_data)
    @user_predictor_event_counts = loaded_data[:predictor_events].inject(Hash.new(0)) do |hash, predictor_event|
      hash[predictor_event.user_id] += 1
      hash
    end
    @user_pageviews = loaded_data[:user_pageviews].inject(Hash.new(0)) do |hash, pageview|
      # pageview.pages raises an error w/ mongoid > 4.0.0
      hash[pageview.user_id] = pageview.raw_attributes["pages"]["_all"]["all_time"]
      hash
    end
    @user_logins = loaded_data[:user_logins].inject(Hash.new(0)) do |hash, login|
      hash[login.user_id] = login["all_time"]["count"]
      hash
    end
    @user_predictor_sessions = loaded_data[:user_predictor_pageviews].inject(Hash.new(0)) do |hash, predictor_pageview|
      hash[predictor_pageview.user_id] = predictor_pageview["all_time"]
      hash
    end
    super
  end

  def pageviews(user, i)
    @user_pageviews[user.id]
  end
{'fraction_non_alphanumeric': 0.11374407582938388, 'fraction_numerical': 0.00631911532385466, 'mean_word_length': 3.716945996275605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2008901', 'n_tokens_mistral': 845, 'n_tokens_neox': 836, 'n_words': 144}