Bump to v1.0.6

This commit is contained in:
Fred Boniface 2023-02-16 22:23:54 +00:00
parent 4e380935e7
commit 297c43a40c
2 changed files with 7 additions and 5 deletions

View File

@ -14,7 +14,7 @@
# program. If not, see
# https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE
version = "1.0.5"
version = "1.0.6"
print(f"main.py: Initialising db-manager v{version}")
#Third Party Imports
@ -27,6 +27,10 @@ import logger as log
log.out("main.py: db-manager Initialised", "INFO")
#Ensure count document exists in meta:
mongo.metaCounters()
#Check & Update corpus/stations:
# If older than 12 days then update
corpusAge = int(time.time()) - mongo.metaCheckTime("corpus")
@ -48,9 +52,6 @@ if corpusAge > 1036800:
mongo.putBulkStations(stationData)
else:
log.out('main.py: Not updating stations data', "INFO")
#Ensure count document exists in meta:
mongo.metaCounters()
# END
log.out(f"main.py: db-manager v{version} Complete", "INFO")

View File

@ -93,13 +93,14 @@ def incrementCounter(target):
def metaCounters():
collection = "meta"
col = db[collection]
incrementCounter(collection)
res = col.find_one({"target": "counters","type": "count"})
log.out(f'mongo.metaCounters: Query returned `{res}`', "DEBG")
if type(res) is dict:
if 'since' in res:
log.out('mongo.metaCounters: counters already exists, skipping', "INFO")
incrementCounter(collection)
return
log.out('mongo.metaCounters: counters does not exist, creating', "INFO")
col.update_one({"target": "counters","type": "count"}, {"$set":{"target": "counters","type": "count","since": int(time.time())}}, upsert=True)
incrementCounter(collection)
return