Skip to content

Commit

Permalink
Move get_quotas into services
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Sep 22, 2023
1 parent c5650e6 commit 1248afd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
16 changes: 0 additions & 16 deletions lib/galaxy/managers/quotas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@
Union,
)

from sqlalchemy import (
false,
select,
true,
)
from sqlalchemy.orm import Session

from galaxy import (
model,
util,
)
from galaxy.exceptions import ActionInputError
from galaxy.managers import base
from galaxy.model import Quota
from galaxy.model.base import transaction
from galaxy.quota import DatabaseQuotaAgent
from galaxy.quota._schema import (
Expand Down Expand Up @@ -281,11 +273,3 @@ def purge_quota(self, quota, params=None):

def get_quota(self, trans, id: int, deleted: Optional[bool] = None) -> model.Quota:
return base.get_object(trans, id, "Quota", check_ownership=False, check_accessible=False, deleted=deleted)


def get_quotas(session: Session, deleted: bool = False):
is_deleted = true()
if not deleted:
is_deleted = false()
stmt = select(Quota).where(Quota.deleted == is_deleted)
return session.scalars(stmt)
21 changes: 17 additions & 4 deletions lib/galaxy/webapps/galaxy/services/quotas.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import logging
from typing import Optional

from sqlalchemy import (
false,
select,
true,
)
from sqlalchemy.orm import Session

from galaxy import util
from galaxy.managers.context import ProvidesUserContext
from galaxy.managers.groups import get_group_by_name
from galaxy.managers.quotas import (
get_quotas,
QuotaManager,
)
from galaxy.managers.quotas import QuotaManager
from galaxy.managers.users import get_user_by_email
from galaxy.model import Quota
from galaxy.quota._schema import (
CreateQuotaParams,
CreateQuotaResult,
Expand Down Expand Up @@ -148,3 +153,11 @@ def get_group_id(item):
raise Exception(msg)
payload["in_users"] = list(map(str, new_in_users))
payload["in_groups"] = list(map(str, new_in_groups))


def get_quotas(session: Session, deleted: bool = False):
is_deleted = true()
if not deleted:
is_deleted = false()
stmt = select(Quota).where(Quota.deleted == is_deleted)
return session.scalars(stmt)

0 comments on commit 1248afd

Please sign in to comment.