Skip to content

Commit

Permalink
Add quota_repo; add get_deleted method; use in services
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Aug 16, 2023
1 parent 5136dd0 commit aebdc8a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/galaxy/webapps/galaxy/services/quotas.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import logging
from typing import Optional

from sqlalchemy import (
false,
select,
true,
)
from sqlalchemy import select

from galaxy import (
model,
util,
)
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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aebdc8a

Please sign in to comment.