Bug Fixes:
- Remove outdated timetable data, - Ensure a 'Delete' transaction only deletes required data - Bump version to 2023.6.6
This commit is contained in:
parent
e52ec43939
commit
2ca5a86030
@ -14,7 +14,7 @@
|
|||||||
# program. If not, see
|
# program. If not, see
|
||||||
# https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE
|
# https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE
|
||||||
|
|
||||||
version = "2023.6.5"
|
version = "2023.6.6"
|
||||||
print(f"main.py: Initialising db-manager v{version}")
|
print(f"main.py: Initialising db-manager v{version}")
|
||||||
|
|
||||||
#Third Party Imports
|
#Third Party Imports
|
||||||
|
@ -141,6 +141,7 @@ def insertSchedule(sch_record):
|
|||||||
return document
|
return document
|
||||||
|
|
||||||
def _insertToDb(data :list, type :str):
|
def _insertToDb(data :list, type :str):
|
||||||
|
pre_count = mongo.getLength("timetable")
|
||||||
try:
|
try:
|
||||||
if type == "full":
|
if type == "full":
|
||||||
mongo.dropCollection("timetable")
|
mongo.dropCollection("timetable")
|
||||||
@ -152,7 +153,9 @@ def _insertToDb(data :list, type :str):
|
|||||||
singleList = [item]
|
singleList = [item]
|
||||||
mongo.putTimetable(singleList)
|
mongo.putTimetable(singleList)
|
||||||
elif item['transactionType'] == "Delete":
|
elif item['transactionType'] == "Delete":
|
||||||
mongo.deleteTimetableData({'trainUid': item['trainUid']}) ## Also need to consider the STP indicator and end date here else I am deleting LTP services when an STP is meant to be deleted.
|
mongo.deleteTimetableData({'trainUid': item['trainUid'], 'scheduleStartDate': item['scheduleStartDate'], 'stpIndicator': item['stpIndicator']}) ## Also need to consider the STP indicator and end date here else I am deleting LTP services when an STP is meant to be deleted.
|
||||||
|
post_count = mongo.getLength("timetable")
|
||||||
|
log.out(f"timetable._insertToDb: Document count difference after processing: {pre_count - post_count}", "DBUG")
|
||||||
return True #If Successfuls
|
return True #If Successfuls
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.out("timetable._insertToDb: Error inserting timetable data", "ERR")
|
log.out("timetable._insertToDb: Error inserting timetable data", "ERR")
|
||||||
@ -201,12 +204,12 @@ def _helpParseDate(string :str, time :str = "false"):
|
|||||||
|
|
||||||
def _removeOutdatedServices():
|
def _removeOutdatedServices():
|
||||||
log.out("timetable._removeOutdatedServices: Removing out of date schedules", "INFO")
|
log.out("timetable._removeOutdatedServices: Removing out of date schedules", "INFO")
|
||||||
preCount = mongo.getLength("timetable")
|
pre_count = mongo.getLength("timetable")
|
||||||
query = {
|
query = {
|
||||||
"schedule_end_date": {
|
"schedule_end_date": {
|
||||||
"$lte": datetime.now()
|
"$lte": datetime.now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
## Important to actually call delete here!!!!
|
mongo.deleteMany("timetable", query)
|
||||||
postCount = mongo.getLength("timetable")
|
post_count = mongo.getLength("timetable")
|
||||||
log.out(f"timetable._removeOutdatedServices: Removed {preCount - postCount} out of date services", "DBUG")
|
log.out(f"timetable._removeOutdatedServices: Removed {pre_count - post_count} out of date services", "DBUG")
|
Reference in New Issue
Block a user