mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-25 08:09:41 +02:00
* refactor(backend): ♻️ cleanup duplicate code in http services * refactor(backend): ♻️ refactor database away from singleton design removed the database single and instead injected the session into a new Database class that is created during each request life-cycle. Now sessions no longer need to be passed into each method on the database All tests pass, but there are likely some hidden breaking changes that were not discovered. * fix venv * disable venv cache * fix install script * bump poetry version * postgres fixes * revert install * fix db initialization for postgres * add postgres to docker * refactor(backend): ♻️ cleanup unused and duplicate code in http services * refactor(backend): remove sessions from arguments * refactor(backend): ♻️ convert units and ingredients to use http service class * test(backend): ✅ add unit and food tests * lint * update tags * re-enable cache * fix missing fraction in db * fix lint Co-authored-by: hay-kot <hay-kot@pm.me>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm.session import Session
|
|
|
|
from mealie.core.config import APP_VERSION, get_settings
|
|
from mealie.db.database import get_database
|
|
from mealie.db.db_setup import generate_session
|
|
from mealie.schema.admin.about import AdminAboutInfo, AppStatistics
|
|
|
|
router = APIRouter(prefix="/about")
|
|
|
|
|
|
@router.get("", response_model=AdminAboutInfo)
|
|
async def get_app_info():
|
|
""" Get general application information """
|
|
settings = get_settings()
|
|
|
|
return AdminAboutInfo(
|
|
production=settings.PRODUCTION,
|
|
version=APP_VERSION,
|
|
demo_status=settings.IS_DEMO,
|
|
api_port=settings.API_PORT,
|
|
api_docs=settings.API_DOCS,
|
|
db_type=settings.DB_ENGINE,
|
|
db_url=settings.DB_URL_PUBLIC,
|
|
default_group=settings.DEFAULT_GROUP,
|
|
)
|
|
|
|
|
|
@router.get("/statistics", response_model=AppStatistics)
|
|
async def get_app_statistics(session: Session = Depends(generate_session)):
|
|
db = get_database(session)
|
|
return AppStatistics(
|
|
total_recipes=db.recipes.count_all(),
|
|
uncategorized_recipes=db.recipes.count_uncategorized(),
|
|
untagged_recipes=db.recipes.count_untagged(),
|
|
total_users=db.users.count_all(),
|
|
total_groups=db.groups.count_all(),
|
|
)
|