Rakshitjan commited on
Commit
19b6ca4
·
verified ·
1 Parent(s): 7142943

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -38
main.py CHANGED
@@ -67,39 +67,10 @@ class MergeRoadmapResponse(BaseModel):
67
  merged_roadmap: str
68
 
69
  def merge_roadmaps(regular_roadmap_str, test_roadmaps_str_list):
70
- # # Convert input strings to JSON
71
- # regular_roadmap = json.loads(regular_roadmap_str)
72
- # test_roadmaps = [json.loads(roadmap) for roadmap in test_roadmaps_str_list]
73
-
74
- # # Helper to convert a roadmap's schedule into a dictionary indexed by dates
75
- # def schedule_to_dict(schedule):
76
- # return {day["date"]: day for day in schedule}
77
-
78
- # # Convert the regular roadmap's schedule to a dictionary
79
- # regular_schedule_dict = schedule_to_dict(regular_roadmap["schedule"])
80
-
81
- # # Process each test roadmap
82
- # for test_roadmap in test_roadmaps:
83
- # # Convert the test roadmap's schedule to a dictionary
84
- # test_schedule_dict = schedule_to_dict(test_roadmap["schedule"])
85
-
86
- # # Merge overlapping dates
87
- # for date, test_day in test_schedule_dict.items():
88
- # if date in regular_schedule_dict:
89
- # # Append test roadmap subjects to matching day in regular roadmap
90
- # if "test_study" not in regular_schedule_dict[date]:
91
- # regular_schedule_dict[date]["test_study"] = []
92
- # regular_schedule_dict[date]["test_study"].extend(test_day["subjects"])
93
-
94
- # # Extend the regular roadmap to include missing days from the test roadmap
95
- # for date, test_day in test_schedule_dict.items():
96
- # if date not in regular_schedule_dict:
97
- # regular_schedule_dict[date] = test_day
98
-
99
- # # Convert the dictionary back to a sorted list
100
- # merged_schedule = sorted(regular_schedule_dict.values(), key=lambda x: x["date"])
101
-
102
- # return {"schedule": merged_schedule}
103
  # Helper to convert a roadmap's schedule into a dictionary indexed by dates
104
  def schedule_to_dict(schedule):
105
  return {day["date"]: day for day in schedule}
@@ -125,13 +96,11 @@ def merge_roadmaps(regular_roadmap_str, test_roadmaps_str_list):
125
  if date not in regular_schedule_dict:
126
  regular_schedule_dict[date] = test_day
127
 
128
- # Convert the dictionary back to a sorted list and filter out the exclude_date
129
- merged_schedule = sorted(
130
- (day for day in regular_schedule_dict.values() if day["date"] != 'YYYY-MM-DD'),
131
- key=lambda x: x["date"]
132
- )
133
 
134
  return {"schedule": merged_schedule}
 
135
 
136
 
137
  @app.post("/merge-roadmaps", response_model=MergeRoadmapResponse)
 
67
  merged_roadmap: str
68
 
69
  def merge_roadmaps(regular_roadmap_str, test_roadmaps_str_list):
70
+ # Convert input strings to JSON
71
+ regular_roadmap = json.loads(regular_roadmap_str)
72
+ test_roadmaps = [json.loads(roadmap) for roadmap in test_roadmaps_str_list]
73
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # Helper to convert a roadmap's schedule into a dictionary indexed by dates
75
  def schedule_to_dict(schedule):
76
  return {day["date"]: day for day in schedule}
 
96
  if date not in regular_schedule_dict:
97
  regular_schedule_dict[date] = test_day
98
 
99
+ # Convert the dictionary back to a sorted list
100
+ merged_schedule = sorted(regular_schedule_dict.values(if day["date"] != 'YYYY-MM-DD'), key=lambda x: x["date"])
 
 
 
101
 
102
  return {"schedule": merged_schedule}
103
+
104
 
105
 
106
  @app.post("/merge-roadmaps", response_model=MergeRoadmapResponse)