@@ -39,22 +39,40 @@ def is_treasurer(self) -> bool:
3939
4040
4141class Board (BaseModel ):
42- start_on : date
42+ start_on : date | None = None
4343 members : list [BoardMember ]
4444
4545 model_config = {"extra" : "forbid" , "frozen" : True }
4646
4747 @property
48- def years (self ) -> tuple [int , int ]:
48+ def years (self ) -> tuple [int , int ] | tuple [None , None ]:
49+ if self .start_on is None :
50+ return None , None
4951 start_year = self .start_on .year
5052 return (start_year , start_year + BOARDS_MANDATE_LENGTH )
5153
54+ @property
55+ def sort_key (self ):
56+ # Boards without a start date sort as starting in the future
57+ if self .start_on is None :
58+ return (1 , None )
59+ return (0 , self .start_on )
60+
5261
5362@cache
5463def load_boards (path : Path | str = BOARDS_CONFIG_PATH ) -> list [Board ]:
64+ """Load all boards, including inactive ones"""
5565 data = tomllib .loads (Path (path ).read_text ())
5666 return sorted (
5767 (Board (** board ) for board in data ["board" ]),
58- key = attrgetter ("start_on" ),
68+ key = attrgetter ('sort_key' ),
5969 reverse = True ,
6070 )
71+
72+ @cache
73+ def load_current_board (path : Path | str = BOARDS_CONFIG_PATH ) -> Board :
74+ """Load the board that is currently in power"""
75+ return [
76+ board for board in load_boards (path )
77+ if board .start_on is not None
78+ ][0 ]
0 commit comments