Skip to content

Commit

Permalink
template
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferrariic committed Nov 16, 2022
1 parent 134ef23 commit 85da6de
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 5 deletions.
5 changes: 2 additions & 3 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import api.middleware
from api.config import app
from api.routers import (
registration,
)
from api.routers import registration, general

app.include_router(registration.router)
app.include_router(general.router)


@app.get("/")
Expand Down
5 changes: 3 additions & 2 deletions api/database/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
from asyncio.tasks import create_task
from collections import namedtuple

from api.config import salt
from api.database.database import USERDATA_ENGINE, Engine
from sqlalchemy import Text, text
from sqlalchemy.exc import InternalError, OperationalError
from sqlalchemy.ext.asyncio import AsyncResult, AsyncSession

from api.config import salt
from api.database.database import USERDATA_ENGINE, Engine

logger = logging.getLogger(__name__)


Expand Down
16 changes: 16 additions & 0 deletions api/database/tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE TABLE `registration` (
`user_id` int NOT NULL AUTO_INCREMENT,
`email` varchar(320) NOT NULL,
`password` tinytext NOT NULL,
`timestamp_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`timestamp_edited` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

CREATE TABLE `tokens` (
`token_id` int NOT NULL AUTO_INCREMENT,
`token` tinytext NOT NULL,
`user_id` int NOT NULL,
`auth_level` int NOT NULL,
PRIMARY KEY (`token_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
146 changes: 146 additions & 0 deletions api/routers/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import json

from fastapi import APIRouter
from pydantic import BaseModel
from typing import List, Optional
from pymysql import Timestamp
import datetime

from api.database.functions import hashbrown, sqlalchemy_result
from api.database.models import Registration, Tokens
from sqlalchemy.sql.expression import select, update
from api.database.database import USERDATA_ENGINE
from fastapi import APIRouter, HTTPException, Request
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.sql.expression import select, update

router = APIRouter()


@router.get("/v1/profiles/{token}", tags=["profile"])
async def get_profile_information(token: str) -> json:
"""returns profile picture string, and user id"""


@router.get("/v1/trainers/{token}", tags=["trainers"])
async def get_trainer_information(token: str) -> json:
"""
Background image: string,
Title: string,
Number of exercises: number,
Difficulty: string
"""


@router.get("/v1/events/{token}", tags=["events"])
async def get_event_information(token: str) -> json:
"""
Params: token:string
{
Background image: string,
Title: string,
Number of exercises: number,
Difficulty: string,
}
"""
pass


@router.get("/v1/dashboard/{token}/{user_id}", tags=["dashboard"])
async def get_dashboard_information(token: str, user_id: str) -> json:
"""
Params:
{
token:string,
User id: number,
}
Returns:
Wallet balance: number,
Earnings total: number,
Taxes total: number,
Hours worked: number,
Sessions worked: number,
Categories assigned: number,
Clients count: number,
Clients profiles: array:string,
Steps: number,
Distance: number,
}
"""
pass


@router.get("/v1/workout/{token}/{user_id}", tags=["workout"])
async def get_workout_plan(token: str, user_id: str) -> json:
"""
Params:
{
Token: string,
User id: number,
}
Returns:
{
Name: string,
Rating: number,
Number of workouts completed: number,
Fitness level: string,
Global stats: array: { title: string, stat: number },
Workout plan: array: array: {workout: string, repts: string, weight: number}
}
"""
pass


@router.get("/v1/profile-details/{token}/{user_id}", tags=["profile"])
async def get_profile_details(token: str, user_id: str) -> json:
"""
Get Profile Details
Params:
{
Token: string,
User id: number,
}
Returns
{
Name: string,
Type: string,
Rating: number,
Rate: number,
About: string,
Goals: array:string,
Number of photos: number,
Partners: number,
Trainers: number,
Gallery: array:string
}
"""
pass


@router.get("/v1/challenge/{token}/{challenge_id}", tags=["challenge"])
async def get_challenge_details(token: str, challenge_id: str) -> json:
"""
Get Challenge Details
Params:
{
Challenge id: number,
Token: string,
}
Returns:
{
Name: string,
Background: string,
Profile picture: string,
Description: string,
Start date: string,
End date: string,
Distance: number,
Reward: string,
Organization: { name: string, image: string, distance: number}
Leaderboard: array: {name: string, pace: number, distance: number}
}
"""
pass
14 changes: 14 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ python -m pip install --upgrade pip
pip install -r requirements.txt
```

## setup if you have multiple versions of python installed
```
pip install virtualenv
# py -m virtualenv -p="C:\Users\thear\AppData\Local\Programs\Python\Python310\python.exe" venv
py -m virtualenv -p="<path to your python.exe>" venv
venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
```

# if the interpreter does not recognize imports, for some reason, use:
ctrl + shift + P > select python interpreter
strl + shift + ` > should work now

# for saving & upgrading
```
venv\Scripts\activate
Expand Down

0 comments on commit 85da6de

Please sign in to comment.