<commit_before>class HomeController < ApplicationController
  def index
    # TODO Refactor this for clarity
    @events = {}
    @max_events_per_normal_section = 6
    populate = lambda do |section, opts|
      leaf = {
        :count => Event.count(:conditions => opts[:conditions]),
        :results => Event.find(:all,
          :conditions => opts[:conditions],
          :limit => (opts[:count] || @max_events_per_normal_section),
          :order => (opts[:order] || 'start_time ASC')),
      }
      leaf[:skipped] = leaf[:count] - (leaf[:results].size || 0)
      @events[section] = leaf
    end
    populate[:today, {
      :conditions => {:start_time => Time.today..(Time.today + 1.days)}}]
    populate[:tomorrow, {
      :conditions => {:start_time => (Time.today + 1.days)..(Time.today + 2.days)}}]
    populate[:later, {
      :conditions => {:start_time => (Time.today + 2.days)..(Time.today + 7.days)}}]
    populate[:recent, {
      :conditions => ['start_time >= ? AND id NOT IN (?)',
        Time.today, @events.values.map{|t| t[:results]}.map(&:id)],
      :limit => 10}]
  end

  # Used by #export
  Mime::Type.register "application/sqlite3", :sqlite3

  # Export the database<commit_msg>Fixed recent events on homepage, they're now guaranteed to be different from those on the 'whats happening' section.<commit_after>class HomeController < ApplicationController
  def index
    # TODO Refactor this for clarity
    @events = {}
    @max_events_per_normal_section = 6
    populate = lambda do |section, opts|
      leaf = {
        :count => Event.count(:conditions => opts[:conditions]),
        :results => Event.find(:all,
          :conditions => opts[:conditions],
          :limit => (opts[:count] || @max_events_per_normal_section),
          :order => (opts[:order] || 'start_time ASC')),
      }
      leaf[:skipped] = leaf[:count] - (leaf[:results].size || 0)
      @events[section] = leaf
    end
    populate[:today, {
      :conditions => {:start_time => Time.today..(Time.today + 1.days)}}]
    populate[:tomorrow, {
      :conditions => {:start_time => (Time.today + 1.days)..(Time.today + 2.days)}}]
    populate[:later, {
      :conditions => {:start_time => (Time.today + 2.days)..(Time.today + 7.days)}}]
    populate[:recent, {
      :conditions => ['start_time >= ? AND id NOT IN (?)',
        Time.today, @events.values.map{|t| t[:results]}.flatten.map(&:id)],
      :limit => 10}]
  end

  # Used by #export
  Mime::Type.register "application/sqlite3", :sqlite3

  # Export the database
{'fraction_non_alphanumeric': 0.17384433030422758, 'fraction_numerical': 0.00869221651521138, 'mean_word_length': 3.031847133757962, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '4719282', 'n_tokens_mistral': 840, 'n_tokens_neox': 777, 'n_words': 174}