Skip to content

Commit 614be75

Browse files
committed
feat: added comments, extra sample file and formatting changes
1 parent 8d76c66 commit 614be75

File tree

6 files changed

+172
-13
lines changed

6 files changed

+172
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
/.vscode/settings.json

conference-planner/app/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ def entrypoint(file_path: str) -> None:
3232
print(event)
3333
data = planner.get_conference_data()
3434
track += 1
35+
print()

conference-planner/planner/generator.py

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from datetime import timedelta
1+
from datetime import date, datetime, timedelta
2+
from typing import List
23

34
from planner.const import PlannerConst
45
from planner.model import Plan
@@ -7,30 +8,31 @@
78

89
class ConferencePlanner:
910
def __init__(self, conference_information: dict) -> None:
10-
# Stack to store networking track
11+
# Store networking track
1112
self.networking_tracks = [
1213
conf_info
1314
for conf_info in conference_information
1415
if conf_info.is_networking_track()
1516
]
17+
# track not networking track is general track
1618
self.general_tracks = list(
1719
set(conference_information) - set(self.networking_tracks)
1820
)
1921
self.planned_track: Plan = Plan(plan=[])
2022

21-
def get_conference_data(self):
23+
def get_conference_data(self) -> List:
2224
return self.general_tracks + self.networking_tracks
2325

2426
def get_plan(self) -> Plan:
2527
"""
26-
Allocate and generate plan
28+
Allocate and generate plan for all sessions
2729
2830
Returns:
2931
Plan: resultant plan
3032
"""
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
3436
sessions = [
3537
(
3638
PlannerConst.MORNING_SESSION,
@@ -54,7 +56,19 @@ def get_plan(self) -> Plan:
5456
self.allocate_track(start, end, track)
5557
return self.planned_track
5658

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+
"""
5872
curr_time = session_start
5973

6074
completed_tracks = []
@@ -77,8 +91,13 @@ def allocate_track(self, session_start, session_end, tracks):
7791
curr_time = end_time
7892
if curr_time == PlannerConst.SESSION_END:
7993
break
94+
8095
# remove completed track from pending tracks
8196
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
82101
if (
83102
session_start == PlannerConst.NETWORKING_SESSION
84103
and not self.is_networking_track_empty()
@@ -88,5 +107,11 @@ def allocate_track(self, session_start, session_end, tracks):
88107

89108
self.general_tracks.remove(completed_track)
90109

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+
"""
92117
return len(self.networking_tracks) == 0

conference-planner/planner/model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def __init__(self, conf_data: dict):
2323

2424
self.name = conf_data[KEYWORD.NAME]
2525
self.duration = conf_data[KEYWORD.DURATION]
26-
26+
2727
if self.duration < 5:
28-
raise ValueError('Duration less than 5 is not supported')
29-
28+
raise ValueError("Duration less than 5 is not supported")
29+
3030
self.is_networking = conf_data[KEYWORD.IS_NETWORKING]
3131

3232
def is_networking_track(self) -> bool:

conference-planner/planner/tests/test_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_model_validator_missing_keys(self):
1010
]
1111
with pytest.raises(Exception):
1212
_ = ConferenceInfo(conference_json_data)
13-
13+
1414
def test_model_validator_less_duration(self):
1515
conference_json_data = [
1616
{"Name": "Overdoing it in Python", "Duration": 4, "isNetworking": False}
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
[
2+
{
3+
"Name": "Writing Fast Tests Against Enterprise Rails",
4+
"Duration": 55,
5+
"isNetworking": false
6+
},
7+
{
8+
"Name": "Overdoing it in Python",
9+
"Duration": 50,
10+
"isNetworking": false
11+
},
12+
{
13+
"Name": "Lua for the Masses",
14+
"Duration": 25,
15+
"isNetworking": false
16+
},
17+
{
18+
"Name": "Ruby Errors from Mismatched Gem Versions",
19+
"Duration": 55,
20+
"isNetworking": false
21+
},
22+
{
23+
"Name": "Common Ruby Errors",
24+
"Duration": 15,
25+
"isNetworking": false
26+
},
27+
{
28+
"Name": "Rails for Python Developers lightning Communicating Over Distance",
29+
"Duration": 90,
30+
"isNetworking": false
31+
},
32+
{
33+
"Name": "Accounting-Driven Development",
34+
"Duration": 25,
35+
"isNetworking": false
36+
},
37+
{
38+
"Name": "Woah",
39+
"Duration": 45,
40+
"isNetworking": false
41+
},
42+
{
43+
"Name": "Sit Down and Write",
44+
"Duration": 5,
45+
"isNetworking": false
46+
},
47+
{
48+
"Name": "Pair Programming vs Noise",
49+
"Duration": 45,
50+
"isNetworking": false
51+
},
52+
{
53+
"Name": "Rails Magic",
54+
"Duration": 60,
55+
"isNetworking": false
56+
},
57+
{
58+
"Name": "User Interface CSS in Rails Apps 2",
59+
"Duration": 15,
60+
"isNetworking": false
61+
},
62+
{
63+
"Name": "Ruby on Rails: Why We Should Move On",
64+
"Duration": 60,
65+
"isNetworking": false
66+
},
67+
{
68+
"Name": "Clojure Ate Scala (on my project)",
69+
"Duration": 45,
70+
"isNetworking": false
71+
},
72+
{
73+
"Name": "Programming in the Boondocks of Seattle",
74+
"Duration": 30,
75+
"isNetworking": false
76+
},
77+
{
78+
"Name": "A World Without HackerNews 2",
79+
"Duration": 10,
80+
"isNetworking": false
81+
},
82+
{
83+
"Name": "Ruby vs. Clojure for Back-End Development",
84+
"Duration": 30,
85+
"isNetworking": false
86+
},
87+
{
88+
"Name": "Ruby on Rails Legacy App Maintenance",
89+
"Duration": 60,
90+
"isNetworking": false
91+
},
92+
{
93+
"Name": "A World Without HackerNews",
94+
"Duration": 30,
95+
"isNetworking": false
96+
},
97+
{
98+
"Name": "User Interface CSS in Rails Apps",
99+
"Duration": 30,
100+
"isNetworking": false
101+
},
102+
{
103+
"Name": "Networking Event: IP",
104+
"Duration": 60,
105+
"isNetworking": true
106+
},
107+
{
108+
"Name": "Networking Event: TCP",
109+
"Duration": 60,
110+
"isNetworking": true
111+
},
112+
{
113+
"Name": "Ruby on Rails Legacy App Maintenance 2",
114+
"Duration": 5,
115+
"isNetworking": false
116+
},
117+
{
118+
"Name": "Programming in the Boondocks of Seattle 2",
119+
"Duration": 20,
120+
"isNetworking": false
121+
},
122+
{
123+
"Name": "Ruby vs. Clojure for Back-End Development 2",
124+
"Duration": 5,
125+
"isNetworking": false
126+
},
127+
{
128+
"Name": "Ruby on Rails Legacy App Maintenance 2",
129+
"Duration": 35,
130+
"isNetworking": false
131+
}
132+
]

0 commit comments

Comments
 (0)