Create new function for getting election information.

This commit is contained in:
2023-07-25 14:50:44 -04:00
parent 9867f91268
commit d67940aa26
+14
View File
@@ -206,3 +206,17 @@ class ElectionCycle:
"""
return f"{self.election_start.year} {self.elecion_cycle.name} election"
def get_election_info(self) -> ElectionInformation:
"""
Gets information for current election.
Returns:
ElectionInformation: The information from the database about the current election.
"""
with Session(engine) as session:
stmt = select(ElectionInformation).where(
ElectionInformation.ElectionCycle == self.get_election_cycle_name()
)
return session.scalar(stmt)