blob: 3da0840a9def8b5bdcf68d9ef01a13bdaaad90f1 (
plain) (
blame)
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
45
46
47
48
49
|
class_name Task
class Task_data:
var id
var name
var description
var frequency
var estimated_length
var date_completed
func _init(record):
self.id = record['id']
self.name = record['name']
self.description = record['description']
self.frequency = record['frequency']
self.estimated_length = record['estimated_length']
self.date_completed = record['date_completed']
static func get_by_id(id):
var record = DBMS.query("""
SELECT * FROM "Tasks"
WHERE id = ?
""",
[id])
record = record[0]
return Task_data.new(record)
static func get_by_timeslot(timeslot_id):
var records = DBMS.query("""
SELECT "Tasks".* FROM "Tasks"
INNER JOIN "TimeSlotTasks" ON "Tasks".id = "TimeSlotTasks".task_id
WHERE "TimeSlotTasks".timeslot_id = ?
""",
[timeslot_id])
var tasks = []
for record in records:
tasks.push_back(Task_data.new(record))
return tasks
static func get_by_frequency(frequency):
var records = DBMS.query("""
SELECT * FROM "Tasks"
WHERE frequency = ?
""",
[frequency])
var tasks = []
for record in records:
tasks.push_back(Task_data.new(record))
return tasks
|