From c5f7d4c20a12d226fdae3cd6806b67c967bc3277 Mon Sep 17 00:00:00 2001 From: jc0b Date: Mon, 3 Aug 2020 16:41:23 +0200 Subject: Removed query_all in prefabs/authorizations in favour of a direct fetch_all on DB --- api/opendc/api/v2/prefabs/authorizations/endpoint.py | 8 +++++--- api/opendc/models/prefab.py | 9 --------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/api/opendc/api/v2/prefabs/authorizations/endpoint.py b/api/opendc/api/v2/prefabs/authorizations/endpoint.py index a6c1aead..b487b9cc 100644 --- a/api/opendc/api/v2/prefabs/authorizations/endpoint.py +++ b/api/opendc/api/v2/prefabs/authorizations/endpoint.py @@ -1,4 +1,5 @@ -from opendc.models.prefab import query_all +from opendc.models.prefab import Prefab +from opendc.util.database import DB from opendc.models.user import User from opendc.util.rest import Response @@ -10,8 +11,9 @@ def GET(request): user.check_exists() - own_prefabs = query_all({'authorId' : user.get_id()}) - public_prefabs = query_all({'visibility' : 'public'}) + + own_prefabs = DB.fetch_all({'authorId' : user.get_id()}, Prefab.collection_name) + public_prefabs = DB.fetch_all({'visibility' : 'public'}, Prefab.collection_name) authorizations = {"authorizations": []} diff --git a/api/opendc/models/prefab.py b/api/opendc/models/prefab.py index e1671dc1..edf1d4c4 100644 --- a/api/opendc/models/prefab.py +++ b/api/opendc/models/prefab.py @@ -1,6 +1,5 @@ from opendc.models.model import Model from opendc.models.user import User -from opendc.util.database import DB from opendc.util.exceptions import ClientError from opendc.util.rest import Response @@ -27,11 +26,3 @@ class Prefab(Model): #except KeyError: # OpenDC-authored objects don't necessarily have an authorId # return - - -def query_all(query): - """Returns a list of all prefabs matching the query. - - :param query: the query to execute on the db. - """ - return DB.fetch_all(query, Prefab.collection_name) -- cgit v1.2.3