diff options
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | data_model/DataHelpers.gd | 52 | ||||
-rw-r--r-- | data_model/SubTask.gd | 48 | ||||
-rw-r--r-- | data_model/Task.gd | 98 | ||||
-rw-r--r-- | data_model/TimeSlot.gd | 78 | ||||
-rw-r--r-- | screens/Task/SubtaskItem.gd | 2 | ||||
-rw-r--r-- | screens/TaskManager/TaskCategory.gd | 2 |
7 files changed, 141 insertions, 141 deletions
diff --git a/.gitattributes b/.gitattributes index 94f480d..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto eol=lf
\ No newline at end of file +* text=auto eol=lf diff --git a/data_model/DataHelpers.gd b/data_model/DataHelpers.gd index 86a05de..3db382e 100644 --- a/data_model/DataHelpers.gd +++ b/data_model/DataHelpers.gd @@ -1,26 +1,26 @@ -class_name DataHelpers
-
-static func dummy_data(data):
- return data
-
-static func timeofday(time):
- time += (Time.get_time_zone_from_system().bias * 60)
- time = Time.get_time_dict_from_unix_time(time)
- var hour = time.hour
- var minute = time.minute
- var am = hour < 12
- hour = hour % 12
- if hour == 0:
- hour = 12
- var string = "%2d:%02d %s"
- return string % [hour, minute, "AM" if am else "PM"]
-
-enum Frequency {DAILY, EVERY_OTHER_DAY, WEEKLY, BI_WEEKLY, MONTHLY, SIZE}
-static func frequency(freq):
- match freq:
- Frequency.DAILY: return "Daily"
- Frequency.EVERY_OTHER_DAY: return "Every\nOther Day"
- Frequency.WEEKLY: return "Weekly"
- Frequency.BI_WEEKLY: return "Bi-Weekly"
- Frequency.MONTHLY: return "Monthly"
- _: return ""
+class_name DataHelpers + +static func dummy_data(data): + return data + +static func timeofday(time): + time += (Time.get_time_zone_from_system().bias * 60) + time = Time.get_time_dict_from_unix_time(time) + var hour = time.hour + var minute = time.minute + var am = hour < 12 + hour = hour % 12 + if hour == 0: + hour = 12 + var string = "%2d:%02d %s" + return string % [hour, minute, "AM" if am else "PM"] + +enum Frequency {DAILY, EVERY_OTHER_DAY, WEEKLY, BI_WEEKLY, MONTHLY, SIZE} +static func frequency(freq): + match freq: + Frequency.DAILY: return "Daily" + Frequency.EVERY_OTHER_DAY: return "Every\nOther Day" + Frequency.WEEKLY: return "Weekly" + Frequency.BI_WEEKLY: return "Bi-Weekly" + Frequency.MONTHLY: return "Monthly" + _: return "" diff --git a/data_model/SubTask.gd b/data_model/SubTask.gd index fa044a5..ffb4d2e 100644 --- a/data_model/SubTask.gd +++ b/data_model/SubTask.gd @@ -1,24 +1,24 @@ -class_name SubTask
-
-class SubTask_data:
- var id
- var task_id
- var name
- var date_completed
-
- func _init(record):
- self.id = record['id']
- self.task_id = record['task_id']
- self.name = record['name']
- self.date_completed = record['date_completed']
-
-static func get_by_task(task_id):
- var records = DBMS.query("""
- SELECT * FROM "SubTasks"
- WHERE task_id = ?
- """,
- [task_id])
- var subtasks = []
- for record in records:
- subtasks.push_back(SubTask_data.new(record))
- return subtasks
+class_name SubTask + +class SubTask_data: + var id + var task_id + var name + var date_completed + + func _init(record): + self.id = record['id'] + self.task_id = record['task_id'] + self.name = record['name'] + self.date_completed = record['date_completed'] + +static func get_by_task(task_id): + var records = DBMS.query(""" + SELECT * FROM "SubTasks" + WHERE task_id = ? + """, + [task_id]) + var subtasks = [] + for record in records: + subtasks.push_back(SubTask_data.new(record)) + return subtasks 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 diff --git a/data_model/TimeSlot.gd b/data_model/TimeSlot.gd index 80b7671..ac1a008 100644 --- a/data_model/TimeSlot.gd +++ b/data_model/TimeSlot.gd @@ -1,39 +1,39 @@ -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_id(id):
- var record = DBMS.query("""
- SELECT * FROM "TimeSlots"
- WHERE id = ?
- """,
- [id])
- record = record[0]
- return TimeSlot_data.new(record)
-
-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
+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_id(id): + var record = DBMS.query(""" + SELECT * FROM "TimeSlots" + WHERE id = ? + """, + [id]) + record = record[0] + return TimeSlot_data.new(record) + +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 diff --git a/screens/Task/SubtaskItem.gd b/screens/Task/SubtaskItem.gd index 157ed5c..afcc337 100644 --- a/screens/Task/SubtaskItem.gd +++ b/screens/Task/SubtaskItem.gd @@ -1,4 +1,4 @@ extends MarginContainer func populate(data): - $"Button".text = data.name
\ No newline at end of file + $"Button".text = data.name diff --git a/screens/TaskManager/TaskCategory.gd b/screens/TaskManager/TaskCategory.gd index ef97c3b..b498b2a 100644 --- a/screens/TaskManager/TaskCategory.gd +++ b/screens/TaskManager/TaskCategory.gd @@ -7,4 +7,4 @@ func populate(data): for task in tasks: var item = TaskItem.instance() item.populate(task) - task_list.add_child(item)
\ No newline at end of file + task_list.add_child(item) |