2023-10-27 23:42:30 +00:00
|
|
|
import logging
|
2023-10-29 09:28:25 +00:00
|
|
|
from peewee import SqliteDatabase, Model, CharField, ForeignKeyField, DateTimeField
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
from textual.logging import TextualHandler
|
2023-10-27 18:32:16 +00:00
|
|
|
|
2023-10-29 13:40:03 +00:00
|
|
|
logger = logging.getLogger("peewee")
|
2023-10-27 23:42:30 +00:00
|
|
|
logger.addHandler(TextualHandler())
|
|
|
|
logger.setLevel(logging.DEBUG)
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
db = SqliteDatabase(None)
|
2023-10-27 03:04:30 +00:00
|
|
|
|
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class HamsterCategory(Model):
|
|
|
|
name = CharField()
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "categories"
|
2023-10-27 18:32:16 +00:00
|
|
|
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class HamsterActivity(Model):
|
|
|
|
name = CharField()
|
2023-10-29 13:40:03 +00:00
|
|
|
category = ForeignKeyField(HamsterCategory, backref="activities")
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "activities"
|
2023-10-27 03:04:30 +00:00
|
|
|
|
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class HamsterFact(Model):
|
2023-10-29 13:40:03 +00:00
|
|
|
activity = ForeignKeyField(HamsterActivity, backref="facts")
|
2023-10-29 09:28:25 +00:00
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField(null=True)
|
|
|
|
description = CharField()
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "facts"
|
2023-10-27 03:04:30 +00:00
|
|
|
|
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class KimaiCustomer(Model):
|
|
|
|
name = CharField()
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "kimai_customers"
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 15:28:46 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class KimaiProject(Model):
|
|
|
|
name = CharField()
|
2023-10-29 13:40:03 +00:00
|
|
|
customer = ForeignKeyField(KimaiCustomer, backref="projects")
|
2023-10-27 15:28:46 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "kimai_projects"
|
2023-10-27 15:28:46 +00:00
|
|
|
|
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class KimaiActivity(Model):
|
|
|
|
name = CharField()
|
2023-10-29 13:40:03 +00:00
|
|
|
project = ForeignKeyField(KimaiProject, backref="activities", null=True)
|
2023-10-27 03:04:30 +00:00
|
|
|
|
2023-10-27 23:42:30 +00:00
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "kimai_activities"
|
2023-10-28 22:40:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HamsterKimaiMapping(Model):
|
2023-10-29 13:40:03 +00:00
|
|
|
hamster_activity = ForeignKeyField(HamsterActivity, backref="mappings")
|
|
|
|
kimai_customer = ForeignKeyField(KimaiCustomer, backref="mappings")
|
|
|
|
kimai_project = ForeignKeyField(KimaiProject, backref="mappings")
|
|
|
|
kimai_activity = ForeignKeyField(KimaiActivity, backref="mappings")
|
2023-10-28 22:40:27 +00:00
|
|
|
kimai_description = CharField()
|
|
|
|
kimai_tags = CharField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
database = db
|
2023-10-29 13:40:03 +00:00
|
|
|
table_name = "hamster_kimai_mappings"
|