Commit 973ad4b3 authored by Mohd Bilal's avatar Mohd Bilal
Browse files

removed duplicates

parent 0ff93ab5
......@@ -409,10 +409,17 @@ class Station(ThreadedModule):
def update_schedule(self, schedule, schedule_type="timgsn"):
existing_schedule = None
settings = None
def find_duplicates():
for o in schedule:
uid = schedule['uid']
with open(f'app/models/{}.json', 'r') as f:
settings = json.load(f)
existing_schedule = settings.get('schedule')
if existing_schedule is not None:
json_schedule = existing_schedule[schedule_type]
if json_schedule:
updated_overpasses = list(filter(lambda x: any([o for o in schedule if o['uid']==x['uid']]), json_schedule))
existing_schedule[schedule_type] = [o for o in json_schedule if o not in updated_overpasses]
settings.update({"schedule": {schedule_type: schedule}})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment