1
- from datetime import timedelta
1
+ from datetime import date , datetime , timedelta
2
+ from typing import List
2
3
3
4
from planner .const import PlannerConst
4
5
from planner .model import Plan
7
8
8
9
class ConferencePlanner :
9
10
def __init__ (self , conference_information : dict ) -> None :
10
- # Stack to store networking track
11
+ # Store networking track
11
12
self .networking_tracks = [
12
13
conf_info
13
14
for conf_info in conference_information
14
15
if conf_info .is_networking_track ()
15
16
]
17
+ # track not networking track is general track
16
18
self .general_tracks = list (
17
19
set (conference_information ) - set (self .networking_tracks )
18
20
)
19
21
self .planned_track : Plan = Plan (plan = [])
20
22
21
- def get_conference_data (self ):
23
+ def get_conference_data (self ) -> List :
22
24
return self .general_tracks + self .networking_tracks
23
25
24
26
def get_plan (self ) -> Plan :
25
27
"""
26
- Allocate and generate plan
28
+ Allocate and generate plan for all sessions
27
29
28
30
Returns:
29
31
Plan: resultant plan
30
32
"""
31
- # List out all sessions
32
- # Note: if there is no networking event,
33
- # allocated general track in networking event time
33
+
34
+ # If there is no networking track, general tracks gets
35
+ # allocated during 4-5 pm
34
36
sessions = [
35
37
(
36
38
PlannerConst .MORNING_SESSION ,
@@ -54,7 +56,19 @@ def get_plan(self) -> Plan:
54
56
self .allocate_track (start , end , track )
55
57
return self .planned_track
56
58
57
- def allocate_track (self , session_start , session_end , tracks ):
59
+ def allocate_track (
60
+ self , session_start : datetime , session_end : datetime , tracks : List [Track ]
61
+ ):
62
+ """
63
+ Allocates track to conference Plan.
64
+ Allocation is done without any preference.
65
+ Once allocation is done, track is removed from general tracks
66
+
67
+ Args:
68
+ session_start (datetime): start time
69
+ session_end (datetime): end time of session
70
+ tracks (List[Track]): list of tracks
71
+ """
58
72
curr_time = session_start
59
73
60
74
completed_tracks = []
@@ -77,8 +91,13 @@ def allocate_track(self, session_start, session_end, tracks):
77
91
curr_time = end_time
78
92
if curr_time == PlannerConst .SESSION_END :
79
93
break
94
+
80
95
# remove completed track from pending tracks
81
96
for completed_track in completed_tracks :
97
+ # Need to remove either general track or network track
98
+ # depending on what track we are allocating
99
+ # If there is no networking track, general tracks gets
100
+ # allocated during 4-5 pm
82
101
if (
83
102
session_start == PlannerConst .NETWORKING_SESSION
84
103
and not self .is_networking_track_empty ()
@@ -88,5 +107,11 @@ def allocate_track(self, session_start, session_end, tracks):
88
107
89
108
self .general_tracks .remove (completed_track )
90
109
91
- def is_networking_track_empty (self ):
110
+ def is_networking_track_empty (self ) -> bool :
111
+ """
112
+ Returns true if no networking tracks are left
113
+
114
+ Returns:
115
+ bool: tre/false depending on length of networking tracks
116
+ """
92
117
return len (self .networking_tracks ) == 0
0 commit comments