Compare commits
No commits in common. "fast-api-rework" and "master" have entirely different histories.
fast-api-r
...
master
19 changed files with 0 additions and 84 deletions
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
fastapi
|
|
||||||
uvicorn[standard]
|
|
||||||
peewee
|
|
|
@ -1 +0,0 @@
|
||||||
DATABASE = "./db.sqlite3"
|
|
|
@ -1,12 +0,0 @@
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from fastapi import APIRouter
|
|
||||||
|
|
||||||
from ..storage import Streak
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list", tags=["streak"])
|
|
||||||
def get_streaks() -> str:
|
|
||||||
return "Hellow"
|
|
21
src/main.py
21
src/main.py
|
@ -1,21 +0,0 @@
|
||||||
from fastapi import FastAPI
|
|
||||||
|
|
||||||
from .config import DATABASE
|
|
||||||
from .storage import *
|
|
||||||
from .endpoints.streak_api import router as streak_router
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
# Setup database
|
|
||||||
def create_database():
|
|
||||||
with database:
|
|
||||||
database.create_tables([Activity, ActivityRecord, Streak, StreakRecord])
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(DATABASE):
|
|
||||||
create_database()
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
app.include_router(streak_router, prefix="/streak", tags=["streak"])
|
|
|
@ -1,3 +0,0 @@
|
||||||
from .activity import Activity, ActivityRecord
|
|
||||||
from .streak import Streak, StreakRecord
|
|
||||||
from .database import database
|
|
|
@ -1,15 +0,0 @@
|
||||||
from .database import BaseModel
|
|
||||||
from peewee import BooleanField, TextField, DateTimeField, ForeignKeyField
|
|
||||||
|
|
||||||
|
|
||||||
class Activity(BaseModel):
|
|
||||||
name = TextField()
|
|
||||||
description = TextField()
|
|
||||||
is_available = BooleanField()
|
|
||||||
is_working = BooleanField()
|
|
||||||
|
|
||||||
|
|
||||||
class ActivityRecord(BaseModel):
|
|
||||||
started_at = DateTimeField()
|
|
||||||
|
|
||||||
activity = ForeignKeyField(Activity, backref='records')
|
|
|
@ -1,12 +0,0 @@
|
||||||
from peewee import Model, SqliteDatabase, UUIDField
|
|
||||||
|
|
||||||
from ..config import DATABASE
|
|
||||||
|
|
||||||
database = SqliteDatabase(DATABASE)
|
|
||||||
|
|
||||||
|
|
||||||
class BaseModel(Model):
|
|
||||||
id = UUIDField(primary_key=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
database = database
|
|
|
@ -1,17 +0,0 @@
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
from .database import BaseModel
|
|
||||||
from peewee import TextField, ForeignKeyField, FloatField, BooleanField, DateField
|
|
||||||
|
|
||||||
|
|
||||||
class Streak(BaseModel):
|
|
||||||
name = TextField()
|
|
||||||
description = TextField
|
|
||||||
|
|
||||||
|
|
||||||
class StreakRecord(BaseModel):
|
|
||||||
reference_date = DateField(default=date.today)
|
|
||||||
is_achieved = BooleanField()
|
|
||||||
value = FloatField()
|
|
||||||
|
|
||||||
streak = ForeignKeyField(Streak, backref='records')
|
|
Loading…
Reference in a new issue