From d67940aa2632a4a997be198b6b89d3f279e105c3 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Tue, 25 Jul 2023 14:50:44 -0400 Subject: [PATCH] Create new function for getting election information. --- classes/election_cycle.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/election_cycle.py b/classes/election_cycle.py index b45f44d..057425f 100644 --- a/classes/election_cycle.py +++ b/classes/election_cycle.py @@ -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)