update time metrics

This commit is contained in:
msramalho
2024-03-12 11:28:49 +00:00
parent 10b0ffa6ee
commit f9ea4c5368
2 changed files with 7 additions and 6 deletions

View File

@@ -71,8 +71,8 @@ def count_archives(db:Session):
def count_archive_urls(db:Session):
return db.query(func.count(models.ArchiveUrl.url)).scalar()
def count_by_user_since(db:Session, time_delta: timedelta = timedelta(seconds=30)):
time_threshold = datetime.now() - time_delta
def count_by_user_since(db:Session, seconds_delta: int = 15):
time_threshold = datetime.now() - timedelta(seconds=seconds_delta)
return db.query(models.Archive.author_id,func.count().label('total'))\
.filter(models.Archive.created_at >= time_threshold)\
.group_by(models.Archive.author_id)\