<commit_before>require 'sinatra'
require 'data_mapper'

get '/' do
  @items = Item.all :order => :id.desc
  erb :home
end

get '/item/:id' do
  @item = Item.get params[:id]
  erb :item
end

get '/item/:id/delete' do
  @item = Item.get params[:id]
  @title= "Confirm deletion of item ##{params[:id]}"
  erb :delete
end

delete '/item/:id' do
  item = Item.get params[:id]
  item.destroy
  redirect '/'
end

post '/' do
  item = Item.new
  item.name = params[:content]
  item.required = params[:required].nil? ? false : params[:required]
  item.save
  redirect '/'
end

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/foodprocessor.db")

class Item
  include DataMapper::Resource
  property :id, Serial
  property :name, Text, :required => true, :unique => true
  property :required, Boolean, :required => true, :default => false
end


DataMapper.finalize.auto_upgrade!<commit_msg>Add more schema<commit_after>require 'sinatra'
require 'data_mapper'

get '/' do
  @items = Item.all :order => :id.desc
  erb :home
end

get '/item/:id' do
  @item = Item.get params[:id]
  erb :item
end

get '/item/:id/delete' do
  @item = Item.get params[:id]
  @title= "Confirm deletion of item ##{params[:id]}"
  erb :delete
end

delete '/item/:id' do
  item = Item.get params[:id]
  item.destroy
  redirect '/'
end

post '/' do
  item = Item.new
  item.name = params[:content]
  item.required = params[:required].nil? ? false : params[:required]
  item.save
  redirect '/'
end

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/foodprocessor.db")


class Unit
  include DataMapper::Resource

  property :id, Serial
  property :name, Text, :required => true, :unique => true
  belongs_to :item
end

class Item
  include DataMapper::Resource

  has 1, :unit
  property :id, Serial
  property :name, Text, :required => true, :unique => true
  property :required, Boolean, :required => true, :default => false
  property :quantity, Integer, :required => true, :default => 1
  belongs_to :event
end

class Event
  include DataMapper::Resource

  has n, :items
  has 1, :link
  property :id, Serial
  property :name, Text, :required => true, :unique => true
  property :date, DateTime, :required => true
  property :created_at, DateTime, :required => true, :default => lambda{ |p,s| DateTime.now}
  property :location, Text
end

class Link
  include DataMapper::Resource

  property :id, Serial
  belongs_to :event
end

class User
  include DataMapper::Resource

  property :id, Serial
  property :name, Text, :required => true
  property :email, Text, :required => true
end

DataMapper.finalize.auto_upgrade!
{'fraction_non_alphanumeric': 0.14258114374034003, 'fraction_numerical': 0.0019319938176197836, 'mean_word_length': 4.007736943907156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '7412976', 'n_tokens_mistral': 871, 'n_tokens_neox': 866, 'n_words': 264}