Fix token list , stats in api app.py (#1896)

### What problem does this PR solve?

#1842 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
H
2024-08-09 19:03:01 +08:00
committed by GitHub
parent 827042f72b
commit fdd5b1b8cf
3 changed files with 14 additions and 6 deletions

View File

@ -45,7 +45,7 @@ class API4ConversationService(CommonService):
@classmethod
@DB.connection_context()
def stats(cls, tenant_id, from_date, to_date):
def stats(cls, tenant_id, from_date, to_date, source=None):
return cls.model.select(
cls.model.create_date.truncate("day").alias("dt"),
peewee.fn.COUNT(
@ -62,5 +62,6 @@ class API4ConversationService(CommonService):
cls.model.thumb_up).alias("thumb_up")
).join(Dialog, on=(cls.model.dialog_id == Dialog.id & Dialog.tenant_id == tenant_id)).where(
cls.model.create_date >= from_date,
cls.model.create_date <= to_date
cls.model.create_date <= to_date,
cls.model.source == source
).group_by(cls.model.create_date.truncate("day")).dicts()