Add TTL index
continuous-integration/drone Build is passing Details

This commit is contained in:
Madis Mägi 2023-09-22 16:48:41 +03:00
parent f6d14671f5
commit e7da187e18
1 changed files with 5 additions and 0 deletions

View File

@ -56,6 +56,9 @@ CLOCK_SKEW_TOLERANCE = timedelta(seconds=3)
# Percentage of blocks active to consider movement in whole frame
THRESHOLD_RATIO = int(os.getenv("THRESHOLD_RATIO", "5"))
# Days to keep events
TTL_DAYS = int(os.getenv("TTL_DAYS", "3"))
CHUNK_BOUNDARY = b"\n--frame\nContent-Type: image/jpeg\n\n"
hist_active_blocks_ratio = Histogram(
@ -560,6 +563,8 @@ async def setup_db(app, loop):
app.ctx.coll.create_index([
("source", pymongo.ASCENDING),
("@timestamp", pymongo.ASCENDING)], unique=True)
app.ctx.coll.create_index(
"@timestamp", expireAfterSeconds=TTL_DAYS*60*60*24)
app.ctx.last_frame = None
app.ctx.event_frame = asyncio.Event()
app.ctx.event_id = None