diff --git a/ER.dia b/ER.dia index defdcfd..987ac8d 100644 Binary files a/ER.dia and b/ER.dia differ diff --git a/ER.png b/ER.png index b597642..77f8f50 100644 Binary files a/ER.png and b/ER.png differ diff --git a/UML.dia b/UML.dia index e1482bd..702bbce 100644 Binary files a/UML.dia and b/UML.dia differ diff --git a/UML.png b/UML.png index c8d8263..1770aa7 100644 Binary files a/UML.png and b/UML.png differ diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index 2012ecf..99e6c73 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -41,10 +41,10 @@ def get_user_by_email(email: str): return user -def create_habit(name: str, user_id: int, times: int, unit: int, list_index: int, note: str | None=None): +def create_habit(name: str, user_id: int, times: int, unit: int, slot: int, note: str | None=None): now = datetime.now().isoformat() query = (f"INSERT INTO habits (user_id, name, note, times, unit, list_index, created_at, updated_at) VALUES ('{user_id}', " - f"'{name}', '{note}', '{times}', '{unit}', '{list_index}', '{now}', '{now}');") + f"'{name}', '{note}', '{times}', '{unit}', '{slot}', '{now}', '{now}');") conn = con3() cursor = conn.cursor() cursor.execute(query) diff --git a/db/migrations/1705434240_delete_habits_table.sql b/db/migrations/1705434240_delete_habits_table.sql new file mode 100644 index 0000000..8d667a0 --- /dev/null +++ b/db/migrations/1705434240_delete_habits_table.sql @@ -0,0 +1 @@ +DROP TABLE habits; diff --git a/db/migrations/1705434260_create_habits_table.sql b/db/migrations/1705434260_create_habits_table.sql new file mode 100644 index 0000000..a38dd47 --- /dev/null +++ b/db/migrations/1705434260_create_habits_table.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS habits +( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + name TEXT NOT NULL, + note TEXT, + times INTEGER NOT NULL, + unit INTEGER, + slot INTEGER NOT NULL, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + FOREIGN KEY (user_id) REFERENCES users(id) +); \ No newline at end of file diff --git a/db/migrations/1705484167_create_test_data.sql b/db/migrations/1705484167_create_test_data.sql new file mode 100644 index 0000000..a5b0d8c --- /dev/null +++ b/db/migrations/1705484167_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO users (name, email, password, created_at, updated_at) + VALUES ('Jan Blodhein', 'dubistdumm@icloud.com', 'a36c101570cc4410993de5385ad7034adb2dae6a05139ac7672577803084634d', '23:00', '23:00'); diff --git a/db/migrations/1705485233_create_test_data.sql b/db/migrations/1705485233_create_test_data.sql new file mode 100644 index 0000000..d8c6f06 --- /dev/null +++ b/db/migrations/1705485233_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO users (name, email, password, created_at, updated_at) + VALUES ('Nikolaus MikeyMouse', 'Nordpol@icloud.com', 'a36c101570cc4410993de5385ad7034adb2dae6a05139ac7672577803084634d', '23:00', '23:00'); diff --git a/db/migrations/1705485243_create_test_data.sql b/db/migrations/1705485243_create_test_data.sql new file mode 100644 index 0000000..a082125 --- /dev/null +++ b/db/migrations/1705485243_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO habits (user_id, name, note, times, unit, slot, created_at, updated_at) + VALUES ('1', 'Sport', '10x Liegestutze', '1', '1', '1', '23:00', '23:00'); diff --git a/db/migrations/1705485247_create_test_data.sql b/db/migrations/1705485247_create_test_data.sql new file mode 100644 index 0000000..236873a --- /dev/null +++ b/db/migrations/1705485247_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO habits (user_id, name, note, times, unit, slot, created_at, updated_at) + VALUES ('1', 'Sport', '10x Klimmzuge', '1', '1', '3', '23:00', '23:00'); diff --git a/db/migrations/1705485251_create_test_data.sql b/db/migrations/1705485251_create_test_data.sql new file mode 100644 index 0000000..1d47ed5 --- /dev/null +++ b/db/migrations/1705485251_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO habits (user_id, name, note, times, unit, slot, created_at, updated_at) + VALUES ('1', 'Essen', '1x Gemüse', '1', '2', '2', '23:00', '23:00'); \ No newline at end of file diff --git a/db/migrations/1705485255_create_test_data.sql b/db/migrations/1705485255_create_test_data.sql new file mode 100644 index 0000000..8584031 --- /dev/null +++ b/db/migrations/1705485255_create_test_data.sql @@ -0,0 +1,2 @@ +INSERT INTO habits (user_id, name, note, times, unit, slot, created_at, updated_at) + VALUES ('2', 'Sport', '10x Liegestutze', '1', '1', '2', '23:00', '23:00'); diff --git a/models/Habit.py b/models/Habit.py index e5a9c8a..7d0f065 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -3,7 +3,7 @@ from db.SQLiteClient import create_habit, get_habits, get_habit # Unit wird als Integers wie folgt gemessen: # 0: Tag -# 1: Woche +# 1: Woche (Default) # 2: Monal # 3: Jahr @@ -15,12 +15,12 @@ class Habit: note: str times: int unit: int - list_index: int + slot: int @staticmethod - def create(user_id: int, name: str, times: int, list_index: int, note: str | None=None, unit: int | None=1): - id = create_habit(user_id, name, note, times, unit, list_index) - return Habit(id, user_id, name, note, times, unit, list_index) + def create(user_id: int, name: str, times: int, slot: int, note: str | None=None, unit: int | None=1): + id = create_habit(user_id, name, note, times, unit, slot) + return Habit(id, user_id, name, note, times, unit, slot) @staticmethod def get(id: int): @@ -34,4 +34,4 @@ class Habit: for habit in raw_habits: habit = Habit(habit[0], habit[1], habit[2], habit[3], habit[4], habit[5], habit[6]) habits.append(habit) - return habits if habits else None \ No newline at end of file + return habits if habits else None