diff options
Diffstat (limited to 'data_model/Task.gd')
-rw-r--r-- | data_model/Task.gd | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/data_model/Task.gd b/data_model/Task.gd index 3da0840..c07d7d1 100644 --- a/data_model/Task.gd +++ b/data_model/Task.gd @@ -1,49 +1,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
+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 |