fix: date filter key not unique (#10645)

This commit is contained in:
Jason Tan
2024-11-16 14:43:55 +08:00
committed by GitHub
parent d05fee1182
commit ca6efd73f3
3 changed files with 30 additions and 25 deletions

View File

@@ -7,7 +7,7 @@ import type { PeriodParams } from '@/app/components/app/overview/appChart'
import { AvgResponseTime, AvgSessionInteractions, AvgUserInteractions, ConversationsChart, CostChart, EndUsersChart, MessagesChart, TokenPerSecond, UserSatisfactionRate, WorkflowCostChart, WorkflowDailyTerminalsChart, WorkflowMessagesChart } from '@/app/components/app/overview/appChart'
import type { Item } from '@/app/components/base/select'
import { SimpleSelect } from '@/app/components/base/select'
import { TIME_PERIOD_LIST } from '@/app/components/app/log/filter'
import { TIME_PERIOD_MAPPING } from '@/app/components/app/log/filter'
import { useStore as useAppStore } from '@/app/components/app/store'
dayjs.extend(quarterOfYear)
@@ -28,7 +28,7 @@ export default function ChartView({ appId }: IChartViewProps) {
const [period, setPeriod] = useState<PeriodParams>({ name: t('appLog.filter.period.last7days'), query: { start: today.subtract(7, 'day').startOf('day').format(queryDateFormat), end: today.endOf('day').format(queryDateFormat) } })
const onSelect = (item: Item) => {
if (item.value === 'all') {
if (item.value === '-1') {
setPeriod({ name: item.name, query: undefined })
}
else if (item.value === 0) {
@@ -49,10 +49,15 @@ export default function ChartView({ appId }: IChartViewProps) {
<div className='flex flex-row items-center mt-8 mb-4 text-gray-900 text-base'>
<span className='mr-3'>{t('appOverview.analysis.title')}</span>
<SimpleSelect
items={TIME_PERIOD_LIST.map(item => ({ value: item.value, name: t(`appLog.filter.period.${item.name}`) }))}
items={Object.entries(TIME_PERIOD_MAPPING).map(([k, v]) => ({ value: k, name: t(`appLog.filter.period.${v.name}`) }))}
className='mt-0 !w-40'
onSelect={onSelect}
defaultValue={7}
onSelect={(item) => {
const id = item.value
const value = TIME_PERIOD_MAPPING[id]?.value || '-1'
const name = item.name || t('appLog.filter.period.allTime')
onSelect({ value, name })
}}
defaultValue={'2'}
/>
</div>
{!isWorkflow && (