-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.rb
executable file
·44 lines (31 loc) · 963 Bytes
/
model.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'data_mapper'
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/worklog.db")
class WorklogEntry
include DataMapper::Resource
property :id, Serial
property :content, Text, :required => true
property :date_performed, DateTime
belongs_to :work_type
belongs_to :work_to_do
end
class WorkType
include DataMapper::Resource
property :id, Serial
property :name, Text, :required => true
has n, :worklog_entries
end
class WorkToDo
include DataMapper::Resource
property :id, Serial
property :name, Text, :required => true
property :complete, Boolean, :required => true, :default => false
property :description, Text
property :star_number, Text
property :created_at, DateTime
property :updated_at, DateTime
has n, :worklog_entries
def self.tasks_worked(filter = {})
all(filter).select{ |t| t.worklog_entries.count > 0 }
end
end
DataMapper.finalize.auto_upgrade!