forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add quota_repo; add get_deleted method; use in services
- Loading branch information
Showing
2 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import ( | ||
cast, | ||
List, | ||
Optional, | ||
) | ||
|
||
from sqlalchemy import ( | ||
false, | ||
select, | ||
true, | ||
) | ||
|
||
from galaxy.model import Quota | ||
from galaxy.model.repositories import ( | ||
BaseRepository, | ||
MappedType, | ||
SessionType, | ||
) | ||
|
||
|
||
class QuotaRepository(BaseRepository): | ||
def __init__(self, session: SessionType, model_class: Optional[MappedType] = None): | ||
model_class = model_class or Quota | ||
super().__init__(session, model_class) | ||
|
||
def get(self, primary_key: int) -> Quota: | ||
return cast(Quota, super().get(primary_key)) | ||
|
||
def get_deleted(self, deleted: bool = True) -> List: | ||
# type-ignore/SessionlessContext | ||
if deleted: | ||
is_deleted = true() | ||
else: | ||
is_deleted = false() | ||
stmt = select(self.model_class).filter(self.model_class.deleted == is_deleted) # type:ignore[attr-defined] | ||
return self.session.scalars(stmt).all() # type:ignore[union-attr] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters