<commit_before>class DashboardsController < ApplicationController
  def index
    breakdowns = {
      last_30_days: 30.days.ago,
      last_3_months: 3.months.ago,
      last_12_months: 12.months.ago
    }

    @dashboard = {results_delivered: {}, percentage_delivered: {}, visits: {}}
    breakdowns.each do |symbol, time|
      delivered = Result.where("recorded_on > ?", time).where.not(:delivery_id => nil).count
      total = Result.where("recorded_on > ?", time).count
      @dashboard[:results_delivered][symbol] = delivered
      @dashboard[:percentage_delivered][symbol] = (100 * delivered.to_f / total).round(0)
      @dashboard[:visits][symbol] = Visit.where("visited_on > ?", time).count
    end

    render "/dashboard"
  end
end<commit_msg>Fix dashboard after change to use deliveries_results join table<commit_after>class DashboardsController < ApplicationController
  def index
    breakdowns = {
      last_30_days: 30.days.ago,
      last_3_months: 3.months.ago,
      last_12_months: 12.months.ago
    }

    @dashboard = {results_delivered: {}, percentage_delivered: {}, visits: {}}
    breakdowns.each do |symbol, time|
      delivered = Result.where("recorded_on > ?", time).includes(:deliveries).where.not(:deliveries_results => {:result_id => nil}).count
      total = Result.where("recorded_on > ?", time).count
      @dashboard[:results_delivered][symbol] = delivered
      @dashboard[:percentage_delivered][symbol] = (100 * delivered.to_f / total).round(0)
      @dashboard[:visits][symbol] = Visit.where("visited_on > ?", time).count
    end

    render "/dashboard"
  end
end
{'fraction_non_alphanumeric': 0.13644859813084112, 'fraction_numerical': 0.017445482866043614, 'mean_word_length': 3.8666666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '7575808', 'n_tokens_mistral': 530, 'n_tokens_neox': 498, 'n_words': 90}