This commit is contained in:
Fred Boniface 2023-06-01 09:07:57 +01:00
parent f961a18486
commit f8e3c0b8bf
3 changed files with 24 additions and 5 deletions

View File

@ -2229,6 +2229,14 @@ pis:
stops: [bnp,umb,egg,lap,mrd,cop,yeo,cdi,ntc,exd,exc] stops: [bnp,umb,egg,lap,mrd,cop,yeo,cdi,ntc,exd,exc]
- code: 6143 - code: 6143
stops: [pnz,ser,hyl,cbn,red,tru,sau,par,los,lsk,men,sgm,sts,ply,ivy,tot,nta,tgm,dwl,exd,tvp,tau,bwt,hig,wsm,wnm,wor,yat,nls,psn,bmt,bri,fit,pwy,stj,nwp,cdf] stops: [pnz,ser,hyl,cbn,red,tru,sau,par,los,lsk,men,sgm,sts,ply,ivy,tot,nta,tgm,dwl,exd,tvp,tau,bwt,hig,wsm,wnm,wor,yat,nls,psn,bmt,bri,fit,pwy,stj,nwp,cdf]
- code: 8001
stops: [pnz,ser,cbn,red,tru,sau,bod,lsk,ply,tot,nta,exd,rdg,pad]
- code: 8002
stops: [pnz,ser,cbn,red,tru,sau,par,bod,lsk,ply,tot,nta,exd,tau,rdg,pad]
- code: 8003
stops: [pad,rdg,exd,nta,ply,lsk,bod,los,par,sau,tru,red,cbn,hyl,ser,pnz]
- code: 8004
stops: [pad,rdg,tau,exd,nta,ply,lsk,bod,los,par,sau,tru,red,cbn,hyl,ser,pnz]
- code: 9801 - code: 9801
stops: [pad,hxx,hwv] stops: [pad,hxx,hwv]
- code: 9802 - code: 9802

View File

@ -187,3 +187,8 @@ def query(collection, query):
col = db[collection] col = db[collection]
incrementCounter(collection) incrementCounter(collection)
return col.find_one(query) return col.find_one(query)
def deleteMany(collection :str, filter :dict):
col = db[collection]
incrementCounter(collection)
return col.delete_many(filter)

View File

@ -96,7 +96,7 @@ def runUpdate():
status = _insertToDb(parsed, required) status = _insertToDb(parsed, required)
if (status): if (status):
mongo.metaUpdateTime("timetable") mongo.metaUpdateTime("timetable")
log.out("timetable.runUpdate: Removing all out of date schedules", "INFO") _removeOutdatedServices()
## Check what happens if there is no update ## Check what happens if there is no update
def insertSchedule(sch_record): def insertSchedule(sch_record):
@ -181,6 +181,12 @@ def _helpParseDate(string :str, time :str = "false"):
return datetime.strptime(string, "%Y-%m-%d %H%M%S") return datetime.strptime(string, "%Y-%m-%d %H%M%S")
def _removeOutdatedServices(): def _removeOutdatedServices():
log.out("timetable._removeOutdatedServices: NOT IMPLEMENTED", "WARN") log.out("timetable._removeOutdatedServices: Removing out of date schedules", "INFO")
# Call 'delete' on all services with an end-date $lte today. preCount = mongo.getLength("timetable")
return query = {
"schedule_end_date": {
"$lte": datetime.now()
}
}
postCount = mongo.getLength("timetable")
log.out(f"timetable._removeOutdatedServices: Removed {preCount - postCount} out of date services", "DBUG")