<commit_before>class DayController < ApplicationController
  get '/:date?', authentication: true do
    @date_string = params[:date] || Date.today.to_s
    date = Date.parse(@date_string)
    @lists = ListRepository.find_by_date(date)

    slim :'day/day'
  end

  post '/:date/list', authentication: true do
    ListRepository.create_empty(params[:title], params[:date])
  end

  private

  def get_date(params)
    date_string = params[:date] || Date.today.to_s
    Date.parse(date_string)
  end
end
<commit_msg>Add endpoints for deleting lists, adding and removing items to/from a list<commit_after>class DayController < ApplicationController
  get '/:date?', authentication: true do |date_string|
    @date_string = date_string || Date.today.to_s
    date = Date.parse(@date_string)
    @lists = List.find_by_date(date, user_id)

    slim :'day/index'
  end

  post '/:date/list', authentication: true do |date|
    List.create_empty(params[:title], date, user_id)
    redirect to "/#{date}"
  end

  delete '/:date/list/:id', authentication: true do |date, id|
    List.delete_by_id(id, user_id)
    redirect to "/#{date}"
  end

  post '/:date/list/:id', authentication: true do |date, id|
    list = List.find_by_id(id, user_id)
    list.add(params[:text]) if list

    redirect to "/#{date}"
  end

  delete '/:date/list/:id/:item_id', authentication: true do |date, list_id, item_id|
    list = List.find_by_id(list_id, user_id)
    list.remove(item_id) if list

    redirect to "/#{date}"
  end
end

{'fraction_non_alphanumeric': 0.13452617627567925, 'fraction_numerical': 0.0, 'mean_word_length': 3.8242811501597442, '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': '6794002', 'n_tokens_mistral': 516, 'n_tokens_neox': 509, 'n_words': 128}