Bump to 0.1.7-test

This commit is contained in:
Fred Boniface 2023-02-13 20:45:05 +00:00
parent 0afcbb4633
commit f3b7ffb3a1
3 changed files with 12 additions and 10 deletions

View File

@ -2,4 +2,4 @@ FROM python:3.11-alpine
COPY ./requirements.txt /app/requirements.txt COPY ./requirements.txt /app/requirements.txt
RUN [ "pip", "install", "-r", "/app/requirements.txt" ] RUN [ "pip", "install", "-r", "/app/requirements.txt" ]
COPY ./src /app/src COPY ./src /app/src
ENTRYPOINT [ "python", "/app/src/test.py" ] CMD [ "python", "/app/src/main.py" ]

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 = "0.1.0" version = "0.1.7"
print(f"main.py: Initialising db-manager v{version}") print(f"main.py: Initialising db-manager v{version}")
#Third Party Imports #Third Party Imports

View File

@ -18,10 +18,10 @@ db = client[db_name]
def metaCheckTime(target): def metaCheckTime(target):
col = db["meta"] col = db["meta"]
res = col.find_one({"target": target, "type": "collection"}) res = col.find_one({"target": target, "type": "collection"})
if type(res) is dict:
if 'updated' in res: if 'updated' in res:
log.out(f'mongo.metaUpdateTime: {target} last updated at {res["updated"]}', "INFO") log.out(f'mongo.metaUpdateTime: {target} last updated at {res["updated"]}', "INFO")
return res["updated"] return res["updated"]
else:
log.out(f'mongo.metaUpdatetime: {target} does not exist', "INFO") log.out(f'mongo.metaUpdatetime: {target} does not exist', "INFO")
return 0 return 0
@ -82,9 +82,11 @@ def metaCounters():
collection = "meta" collection = "meta"
col = db[collection] col = db[collection]
res = col.find_one({"target": "counters","type": "count"}) res = col.find_one({"target": "counters","type": "count"})
if 'since' not in res: log.out(f'mongo.metaCounters: Query returned `{res}`', "DEBG")
log.out('mongo.metaCounters: counters does not exist, creating', "INFO") if type(res) is dict:
col.update_one({"target": "counters","type": "count"}, {"target": "counters","type": "count","since": int(time.time())}) if 'since' in res:
else:
log.out('mongo.metaCounters: counters already exists, skipping', "INFO") log.out('mongo.metaCounters: counters already exists, skipping', "INFO")
return 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)
return