def _get_oldest_event_timestamp(self):
"""Search for the oldest event timestamp."""
# Retrieve the oldest event in order to start aggregation
# from there
query_events = Search(
using=self.client,
index=self.event_index
)[0:1].sort(
{'timestamp': {'order': 'asc'}}
)
result = query_events.execute()
# There might not be any events yet if the first event have been
# indexed but the indices have not been refreshed yet.
if len(result) == 0:
return None
return parser.parse(result[0]['timestamp'])
评论列表
文章目录