-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add patch for sbl institution types
- Loading branch information
1 parent
ff20bdb
commit 8c30d9b
Showing
8 changed files
with
161 additions
and
21 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
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
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
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
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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
from sqlalchemy import select | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
from typing import List, TypeVar | ||
from typing import Sequence, TypeVar, Type | ||
from entities.models import Base, SblTypeMappingDao, SblTypeAssociationDto | ||
|
||
T = TypeVar("T") | ||
T = TypeVar("T", bound=Base) | ||
|
||
|
||
async def query_type(session: AsyncSession, type: T) -> List[T]: | ||
async def query_type(session: AsyncSession, type: Type[T]) -> Sequence[T]: | ||
async with session.begin(): | ||
stmt = select(type) | ||
res = await session.scalars(stmt) | ||
return res.all() | ||
|
||
|
||
def get_associated_sbl_types( | ||
lei: str, user_id: str, types: Sequence[SblTypeAssociationDto | str] | ||
) -> Sequence[SblTypeMappingDao]: | ||
return [ | ||
SblTypeMappingDao(type_id=t, lei=lei, modified_by=user_id) | ||
if isinstance(t, str) | ||
else SblTypeMappingDao(type_id=t.id, details=t.details, lei=lei, modified_by=user_id) | ||
for t in types | ||
] |
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
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
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