move functions to get election cycle index and name into utils.
build_develop / build (push) Successful in 1m52s
build_develop / build (push) Successful in 1m52s
This commit is contained in:
@@ -35,6 +35,30 @@ def get_election_cycle_name(config: DakinyConfig) -> str:
|
||||
Returns:
|
||||
str: the name of the election cycle
|
||||
"""
|
||||
# TODO finish
|
||||
cycle = get_current_cycle(config)
|
||||
current_cycle = config.election_cycles[cycle]
|
||||
|
||||
return f"vote-{election_start.year}-{election_cycle.name}"
|
||||
return f"vote-{get_datetime(current_cycle.election_start).year}-{current_cycle.name}"
|
||||
|
||||
|
||||
def get_current_cycle(config: DakinyConfig) -> 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. -1 for no active cycle
|
||||
"""
|
||||
|
||||
today = datetime.today()
|
||||
|
||||
for cycle, election in enumerate(config.election_cycles):
|
||||
if (
|
||||
today.date() >= get_datetime(election.election_start).date()
|
||||
and today.date() <= get_datetime(election.term_start).date()
|
||||
):
|
||||
return cycle
|
||||
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user