changed name convention

For the Habit Model:
list_index -> slot
This commit is contained in:
Yapollon 2024-01-17 10:32:52 +01:00
parent e7d50f1eb8
commit 43cc847008
8 changed files with 21 additions and 7 deletions

BIN
ER.dia

Binary file not shown.

BIN
ER.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
UML.dia

Binary file not shown.

BIN
UML.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -41,10 +41,10 @@ def get_user_by_email(email: str):
return user 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() now = datetime.now().isoformat()
query = (f"INSERT INTO habits (user_id, name, note, times, unit, list_index, created_at, updated_at) VALUES ('{user_id}', " 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() conn = con3()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute(query) cursor.execute(query)

View File

@ -0,0 +1 @@
DROP TABLE habits;

View File

@ -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)
);

View File

@ -3,7 +3,7 @@ from db.SQLiteClient import create_habit, get_habits, get_habit
# Unit wird als Integers wie folgt gemessen: # Unit wird als Integers wie folgt gemessen:
# 0: Tag # 0: Tag
# 1: Woche # 1: Woche (Default)
# 2: Monal # 2: Monal
# 3: Jahr # 3: Jahr
@ -15,12 +15,12 @@ class Habit:
note: str note: str
times: int times: int
unit: int unit: int
list_index: int slot: int
@staticmethod @staticmethod
def create(user_id: int, name: str, times: int, list_index: int, note: str | None=None, unit: int | None=1): 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, list_index) id = create_habit(user_id, name, note, times, unit, slot)
return Habit(id, user_id, name, note, times, unit, list_index) return Habit(id, user_id, name, note, times, unit, slot)
@staticmethod @staticmethod
def get(id: int): def get(id: int):