2024-03-27 09:25:37 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: application_statistics_api.py
|
|
|
|
|
|
@date:2024/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 _
|
2024-03-27 09:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
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')),
|
2024-03-28 08:06:54 +00:00
|
|
|
|
openapi.Parameter(name='start_time',
|
2024-03-27 09:25:37 +00:00
|
|
|
|
in_=openapi.IN_QUERY,
|
2024-03-28 08:06:54 +00:00
|
|
|
|
type=openapi.TYPE_STRING,
|
2024-03-27 09:25:37 +00:00
|
|
|
|
required=True,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
description=_('Start time')),
|
2024-03-28 08:06:54 +00:00
|
|
|
|
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')),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
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'],
|
2024-03-27 09:25:37 +00:00
|
|
|
|
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")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
|
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")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
'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")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
'day': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 11:05:08 +00:00
|
|
|
|
title=_("time"),
|
|
|
|
|
|
description=_("time")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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")),
|
2024-03-27 09:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|