<commit_before>class Home < App
  get '/' do
    Entry.all.to_json
  end

  get '/today' do
    today = DateTime.current.wday
    Entry.where(day_of_week: today).to_json
  end

  get '/on/:day_of_week' do
    day_of_week_id = Date::DAYNAMES.index(params["day_of_week"].capitalize)
    halt 422, { message: 'Unknown day of week' }.to_json if day_of_week_id.nil?

    Entry.where(day_of_week: day_of_week_id).to_json
  end

  post '/' do
    entry = Entry.new(params)

    if entry.save
      SlackNotificator.new("New entry from device: _#{entry.device_id || 'unknown'}_.").call
      entry.to_json
    else
      halt 422, entry.errors.to_json
    end
  end

  delete '/:id' do
    if AppConfig["delete_tokens"].exclude?(params["token"])
      halt 403, { message: "Wrong token" }.to_json
    end

    entry = Entry.find(params["id"])
    entry.destroy.to_json
  end
end<commit_msg>rename home controller according to the new convention<commit_after>class HomeController < App
  get '/' do
    Entry.all.to_json
  end

  get '/today' do
    today = DateTime.current.wday
    Entry.where(day_of_week: today).to_json
  end

  get '/on/:day_of_week' do
    day_of_week_id = Date::DAYNAMES.index(params["day_of_week"].capitalize)
    halt 422, { message: 'Unknown day of week' }.to_json if day_of_week_id.nil?

    Entry.where(day_of_week: day_of_week_id).to_json
  end

  post '/' do
    entry = Entry.new(params)

    if entry.save
      SlackNotificator.new("New entry from device: _#{entry.device_id || 'unknown'}_.").call
      entry.to_json
    else
      halt 422, entry.errors.to_json
    end
  end

  delete '/:id' do
    if AppConfig["delete_tokens"].exclude?(params["token"])
      halt 403, { message: "Wrong token" }.to_json
    end

    entry = Entry.find(params["id"])
    entry.destroy.to_json
  end
end
{'fraction_non_alphanumeric': 0.12231404958677686, 'fraction_numerical': 0.009917355371900827, 'mean_word_length': 3.1085972850678734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6113845', 'n_tokens_mistral': 679, 'n_tokens_neox': 645, 'n_words': 144}