33from datetime import datetime
44
55import sqlalchemy
6+ from sqlalchemy .ext .asyncio import AsyncSession
67
78import database
89from elections .tables import Election
@@ -26,7 +27,7 @@ class ElectionParameters:
2627
2728_logger = logging .getLogger (__name__ )
2829
29- async def get_election (db_session : database . DBSession , election_slug : str ) -> Election | None :
30+ async def get_election (db_session : AsyncSession , election_slug : str ) -> Election | None :
3031 query = (
3132 sqlalchemy
3233 .select (Election )
@@ -35,7 +36,7 @@ async def get_election(db_session: database.DBSession, election_slug: str) -> El
3536 result = await db_session .scalar (query )
3637 return result
3738
38- async def create_election (params : ElectionParameters , db_session : database . DBSession ) -> None :
39+ async def create_election (db_session : AsyncSession , params : ElectionParameters ) -> None :
3940 """
4041 Creates a new election with given parameters.
4142 Does not validate if an election _already_ exists
@@ -49,15 +50,15 @@ async def create_election(params: ElectionParameters, db_session: database.DBSes
4950 survey_link = params .survey_link )
5051 db_session .add (election )
5152
52- async def delete_election (slug : str , db_session : database . DBSession ) -> None :
53+ async def delete_election (db_session : AsyncSession , slug : str ) -> None :
5354 """
5455 Deletes a given election by its slug.
5556 Does not validate if an election exists
5657 """
5758 query = sqlalchemy .delete (Election ).where (Election .slug == slug )
5859 await db_session .execute (query )
5960
60- async def update_election (params : ElectionParameters , db_session : database . DBSession ) -> None :
61+ async def update_election (db_session : AsyncSession , params : ElectionParameters ) -> None :
6162 """
6263 Updates an election with the provided parameters.
6364 Take care as this will replace values with None if not populated.
0 commit comments