diff --git a/src/corpus.py b/src/corpus.py index 2e63767..0c63997 100644 --- a/src/corpus.py +++ b/src/corpus.py @@ -16,7 +16,7 @@ CORPUS_PASS = os.getenv('OWL_LDB_CORPUSPASS') def fetch(): log.out("corpus.fetch: Fetching CORPUS Data from Network Rail", "INFO") response = requests.get(CORPUS_URL, auth=(CORPUS_USER, CORPUS_PASS)) - incrementCounter("corpus_api") + mongo.incrementCounter("corpus_api") log.out("corpus.fetch: Decompressing & parsing CORPUS data", "INFO") parsed = json.loads(zlib.decompress(response.content, 16+zlib.MAX_WBITS).decode()) return parsed['TIPLOCDATA'] diff --git a/src/main.py b/src/main.py index 901b20b..d5e8a43 100644 --- a/src/main.py +++ b/src/main.py @@ -14,7 +14,7 @@ # program. If not, see # https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE -version = "1.0.0" +version = "1.0.5" print(f"main.py: Initialising db-manager v{version}") #Third Party Imports @@ -36,14 +36,14 @@ if corpusAge > 1036800: corpusData = corpus.removeEmpty(corpus.fetch()) mongo.putBulkCorpus(corpusData) else: - log.out('main.py: Not updating CORPUS data', "INFO") + log.out('main.py: Not updating CORPUS data until it is 1036800s old.', "INFO") stationsAge = int(time.time()) - mongo.metaCheckTime("stations") log.out(f'main.py: Stations is {stationsAge}s old', "INFO") # While the source of stations data is CORPUS, this statement is based on corpusAge, when/if changing the source, it should be changed to use stationsAge # if stationsAge is used now, there could be a situation where stationsAge tries to update but fails as corpusData doesn't exist. if corpusAge > 1036800: - log.out('main.py: Updating stations data', "INFO") + log.out('main.py: Updating stations data until it is 1036800s old.', "INFO") stationData = corpus.onlyStations(corpusData) mongo.putBulkStations(stationData) else: diff --git a/src/mongo.py b/src/mongo.py index 08380a2..a8668a0 100644 --- a/src/mongo.py +++ b/src/mongo.py @@ -86,7 +86,8 @@ def putBulkStations(data): def incrementCounter(target): collection = "meta" col = db[collection] - col.update_one({"target": "counters"}, {"$inc":target}) + log.out(f'mongo.incrementCounter: Incrementing counter for {target}', "INFO") + col.update_one({"target": "counters","type": "count"}, {"$inc":{target: 1}}) return def metaCounters():