diff --git a/src/main.py b/src/main.py index 8e8681c..7652a8f 100644 --- a/src/main.py +++ b/src/main.py @@ -53,6 +53,10 @@ if corpusAge > 1036800: else: log.out('main.py: Not updating stations data', "INFO") +log.out('main.py: Requesting TTL Index Creation', "INFO") +mongo.createTtlIndex("users", "atime", 31557600) +mongo.createTtlIndex("registrations", "time", 1800) + # Push version number to database for reporting mongo.putVersion(version) diff --git a/src/mongo.py b/src/mongo.py index 57712d2..fda809c 100644 --- a/src/mongo.py +++ b/src/mongo.py @@ -44,6 +44,11 @@ def createSingleIndex(collection, field): log.out(f'mongo.createSingleIndex: Created index of {field} in {collection}', "INFO") return +def createTtlIndex(collection, field, time): + col = db[collection] + col.create_index(field, expireAfterSeconds = time) + log.out(f'mongo.createTtlIndex: Created TTL Index of {field} in {collection} to expire after {time} seconds', "INFO") + def putBulkCorpus(data): collection = "corpus" startCount = getLength(collection)