Create new function for getting election information.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user