summaryrefslogtreecommitdiffstats
path: root/data_model/TimeSlot.gd
diff options
context:
space:
mode:
Diffstat (limited to 'data_model/TimeSlot.gd')
-rw-r--r--data_model/TimeSlot.gd30
1 files changed, 30 insertions, 0 deletions
diff --git a/data_model/TimeSlot.gd b/data_model/TimeSlot.gd
new file mode 100644
index 0000000..f98cd62
--- /dev/null
+++ b/data_model/TimeSlot.gd
@@ -0,0 +1,30 @@
+class_name TimeSlot
+
+class TimeSlot_data:
+ var id
+ var schedule_id
+ var start_time
+ var end_time
+ var name
+ var date_completed
+
+ func _init(record):
+ self.id = record['id']
+ self.schedule_id = record['schedule_id']
+ self.start_time = record['start_time']
+ self.end_time = record['end_time']
+ self.name = record['name']
+ self.date_completed = record['date_completed']
+
+static func get_by_schedule_name(schedule_name):
+ var records = DBMS.query("""
+ SELECT "TimeSlots".* FROM "TimeSlots"
+ JOIN "Schedules" ON "TimeSlots".schedule_id = "Schedules".id
+ WHERE "Schedules".name = ?
+ ORDER BY "TimeSlots".start_time
+ """,
+ [schedule_name])
+ var timeslots = []
+ for record in records:
+ timeslots.push_back(TimeSlot_data.new(record))
+ return timeslots