Remove config param from get_quarter_cycle().

This commit is contained in:
2024-09-03 16:08:27 -04:00
parent 62f9902298
commit f81e95381e
+4 -13
View File
@@ -73,13 +73,10 @@ def get_quarter_name() -> str:
"""
Builds the name of the current cycle/quarter.
Args:
config (DakinyConfig): the config used to know the election cycle.
Returns:
str: the name of the cycle.
"""
cycle = get_quarter_cycle(settings)
cycle = get_quarter_cycle()
current_cycle = settings.election_cycles[cycle]
return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
@@ -89,9 +86,6 @@ def get_current_election_cycle() -> int:
"""
Returns index for active election. An election is considered active between the election start and the term start.
Args:
config (DakinyConfig): Config object to use
Returns:
int: cycle index for active election. None for no active cycle
"""
@@ -105,21 +99,18 @@ def get_current_election_cycle() -> int:
return cycle
# It isn't a current election, get the quarter
return get_quarter_cycle(settings)
return get_quarter_cycle()
def get_quarter_cycle(config: DakinySettings) -> int:
def get_quarter_cycle() -> int:
"""
Returns the index for the current cycle/quarter. Defined as between term start and end. Shouldn't return none.
Args:
config (DakinyConfig): Config object to use
Returns:
int: cycle index for current cycle.
"""
today = datetime.now(tz=UTC)
for cycle, election in enumerate(config.election_cycles):
for cycle, election in enumerate(settings.election_cycles):
if (
today.date() >= get_datetime(election.term_start).date()
and today.date() <= get_datetime(election.term_end).date()