UnisKB/apps/application/swagger_api/application_statistics_api.py

87 lines
4.1 KiB
Python
Raw Normal View History

# coding=utf-8
"""
@project: maxkb
@Author
@file application_statistics_api.py
@date2024/3/27 15:09
@desc:
"""
from drf_yasg import openapi
from common.mixins.api_mixin import ApiMixin
2025-01-13 11:05:08 +00:00
from django.utils.translation import gettext_lazy as _
class ApplicationStatisticsApi(ApiMixin):
@staticmethod
def get_request_params_api():
return [openapi.Parameter(name='application_id',
in_=openapi.IN_PATH,
type=openapi.TYPE_STRING,
required=True,
2025-01-13 11:05:08 +00:00
description=_('Application ID')),
openapi.Parameter(name='start_time',
in_=openapi.IN_QUERY,
type=openapi.TYPE_STRING,
required=True,
2025-01-13 11:05:08 +00:00
description=_('Start time')),
openapi.Parameter(name='end_time',
in_=openapi.IN_QUERY,
type=openapi.TYPE_STRING,
required=True,
2025-01-13 11:05:08 +00:00
description=_('End time')),
]
class ChatRecordAggregate(ApiMixin):
@staticmethod
def get_response_body_api():
return openapi.Schema(
type=openapi.TYPE_OBJECT,
2024-03-27 09:34:46 +00:00
required=['star_num', 'trample_num', 'tokens_num', 'chat_record_count'],
properties={
2025-01-13 11:05:08 +00:00
'star_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of Likes"),
description=_("Number of Likes")),
2025-01-13 11:05:08 +00:00
'trample_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of thumbs-downs"), description=_("Number of thumbs-downs")),
'tokens_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of tokens used"),
description=_("Number of tokens used")),
'chat_record_count': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of conversations"),
description=_("Number of conversations")),
'customer_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of customers"),
description=_("Number of customers")),
'customer_added_count': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Number of new customers"),
description=_("Number of new customers")),
'day': openapi.Schema(type=openapi.TYPE_STRING,
2025-01-13 11:05:08 +00:00
title=_("time"),
description=_("Time, this field is only available when querying trends")),
}
)
class CustomerCountTrend(ApiMixin):
@staticmethod
def get_response_body_api():
return openapi.Schema(
type=openapi.TYPE_OBJECT,
required=['added_count'],
properties={
2025-01-13 11:05:08 +00:00
'added_count': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("New quantity"), description=_("New quantity")),
'day': openapi.Schema(type=openapi.TYPE_STRING,
2025-01-13 11:05:08 +00:00
title=_("time"),
description=_("time")),
}
)
class CustomerCount(ApiMixin):
@staticmethod
def get_response_body_api():
return openapi.Schema(
type=openapi.TYPE_OBJECT,
required=['added_count'],
properties={
2025-01-13 11:05:08 +00:00
'today_added_count': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("Today's new quantity"),
description=_("Today's new quantity")),
'added_count': openapi.Schema(type=openapi.TYPE_NUMBER, title=_("New quantity"), description=_("New quantity")),
}
)