Skip to content

Commit

Permalink
bf(UTAPI-109): Round reindex timestamp correctly to 15 minute interval
Browse files Browse the repository at this point in the history
  • Loading branch information
tmacro committed Oct 14, 2024
1 parent 9ccb24d commit e6ba36c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/reindex/s3_bucketd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import uuid
from collections import namedtuple
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime

import redis
import requests
Expand Down Expand Up @@ -384,7 +385,12 @@ def get_redis_client(options):
)

def update_redis(client, resource, name, obj_count, total_size):
timestamp = int(time.time() - 15 * 60) * 1000
now = datetime.utcnow()
# Round down to the nearest 15 minute interval
rounded_minute = now.minute - (now.minute % 15)
now = now.replace(minute=rounded_minute, second=0, microsecond=0)
# Convert to milliseconds
timestamp = int(now.timestamp()) * 1000
obj_count_key = 's3:%s:%s:numberOfObjects' % (resource, name)
total_size_key = 's3:%s:%s:storageUtilized' % (resource, name)
obj_count_serialized = f"{obj_count}:{uuid.uuid4()}"
Expand Down

0 comments on commit e6ba36c

Please sign in to comment.