From aebdc8aa5e0368968b2cf400f66742054ed98b9f Mon Sep 17 00:00:00 2001 From: John Davis Date: Tue, 15 Aug 2023 15:20:23 -0400 Subject: [PATCH] Add quota_repo; add get_deleted method; use in services --- lib/galaxy/webapps/galaxy/services/quotas.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/services/quotas.py b/lib/galaxy/webapps/galaxy/services/quotas.py index 95cfb97f6195..47f7954afbda 100644 --- a/lib/galaxy/webapps/galaxy/services/quotas.py +++ b/lib/galaxy/webapps/galaxy/services/quotas.py @@ -1,11 +1,7 @@ import logging from typing import Optional -from sqlalchemy import ( - false, - select, - true, -) +from sqlalchemy import select from galaxy import ( model, @@ -13,6 +9,7 @@ ) from galaxy.managers.context import ProvidesUserContext from galaxy.managers.quotas import QuotaManager +from galaxy.model.repositories.quota import QuotaRepository from galaxy.quota._schema import ( CreateQuotaParams, CreateQuotaResult, @@ -40,14 +37,14 @@ def __init__(self, security: IdEncodingHelper, quota_manager: QuotaManager): def index(self, trans: ProvidesUserContext, deleted: bool = False) -> QuotaSummaryList: """Displays a list of quotas.""" rval = [] - stmt = select(model.Quota) + quota_repo = QuotaRepository(trans.sa_session) if deleted: route = "deleted_quota" - stmt = stmt.filter(model.Quota.deleted == true()) + quotas = quota_repo.get_deleted() else: route = "quota" - stmt = stmt.filter(model.Quota.deleted == false()) - for quota in trans.sa_session.scalars(stmt): + quotas = quota_repo.get_deleted(False) + for quota in quotas: item = quota.to_dict(value_mapper={"id": DecodedDatabaseIdField.encode}) encoded_id = DecodedDatabaseIdField.encode(quota.id) item["url"] = url_for(route, id=encoded_id)