From d8d20f422483b72092c26f332543a563aa1ed048 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 15 Jun 2021 20:31:51 -0700 Subject: [PATCH] Add backend functions for a basic dashboard --- amanuensis/backend/lexicon.py | 6 ++++++ amanuensis/backend/user.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/amanuensis/backend/lexicon.py b/amanuensis/backend/lexicon.py index 18bbe84..726b360 100644 --- a/amanuensis/backend/lexicon.py +++ b/amanuensis/backend/lexicon.py @@ -3,6 +3,7 @@ Lexicon query interface """ import re +from typing import Sequence from sqlalchemy import select, func @@ -52,3 +53,8 @@ def create( db.session.add(new_lexicon) db.session.commit() return new_lexicon + + +def get_all_lexicons(db: DbContext) -> Sequence[Lexicon]: + """Get all lexicons.""" + return db(select(Lexicon)).scalars() diff --git a/amanuensis/backend/user.py b/amanuensis/backend/user.py index 5411079..4ff2264 100644 --- a/amanuensis/backend/user.py +++ b/amanuensis/backend/user.py @@ -3,7 +3,7 @@ User query interface """ import re -import uuid +from typing import Sequence from sqlalchemy import select, func @@ -67,3 +67,8 @@ def create( db.session.add(new_user) db.session.commit() return new_user + + +def get_all_users(db: DbContext) -> Sequence[User]: + """Get all users.""" + return db(select(User)).scalars()