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 # 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 = "1.0.5" version = "1.0.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
@ -27,6 +27,10 @@ import logger as log
log.out("main.py: db-manager Initialised", "INFO") log.out("main.py: db-manager Initialised", "INFO")
#Ensure count document exists in meta:
mongo.metaCounters()
#Check & Update corpus/stations: #Check & Update corpus/stations:
# If older than 12 days then update # If older than 12 days then update
corpusAge = int(time.time()) - mongo.metaCheckTime("corpus") corpusAge = int(time.time()) - mongo.metaCheckTime("corpus")
@ -49,8 +53,5 @@ if corpusAge > 1036800:
else: else:
log.out('main.py: Not updating stations data', "INFO") log.out('main.py: Not updating stations data', "INFO")
#Ensure count document exists in meta:
mongo.metaCounters()
# END # END
log.out(f"main.py: db-manager v{version} Complete", "INFO") log.out(f"main.py: db-manager v{version} Complete", "INFO")

View File

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