summaryrefslogtreecommitdiffstats
path: root/data_model/Task.gd
diff options
context:
space:
mode:
Diffstat (limited to 'data_model/Task.gd')
-rw-r--r--data_model/Task.gd49
1 files changed, 49 insertions, 0 deletions
diff --git a/data_model/Task.gd b/data_model/Task.gd
new file mode 100644
index 0000000..3da0840
--- /dev/null
+++ b/data_model/Task.gd
@@ -0,0 +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