Skip to content

Commit

Permalink
🐛 fix: fix stats data query issue (#5283)
Browse files Browse the repository at this point in the history
* update locale

* fix: fix user id query

* fix

* fix modal text
  • Loading branch information
arvinxx authored Jan 3, 2025
1 parent bb23f58 commit f3fdee7
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 8 deletions.
7 changes: 7 additions & 0 deletions locales/ar/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "لا توجد بيانات"
},
"lastYearActivity": "النشاط في العام الماضي",
"loginGuide": {
"f1": "احصل على استخدام مجاني",
"f2": "مزامنة الرسائل عبر الأجهزة المتعددة",
"f3": "تمتع بمساعدين متنوعين",
"f4": "استكشف الإضافات القوية",
"title": "بعد تسجيل الدخول يمكنك:"
},
"messages": "رسائل",
"modelsRank": {
"left": "النموذج",
Expand Down
7 changes: 7 additions & 0 deletions locales/bg-BG/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Няма данни"
},
"lastYearActivity": "активност през последната година",
"loginGuide": {
"f1": "Получете безплатен лимит",
"f2": "Синхронизирайте съобщения на множество устройства",
"f3": "Разполагайте с богат асистент",
"f4": "Изследвайте мощни приставки",
"title": "След влизане можете да:"
},
"messages": "Съобщения",
"modelsRank": {
"left": "Модел",
Expand Down
7 changes: 7 additions & 0 deletions locales/de-DE/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Keine Daten"
},
"lastYearActivity": "Aktivität im letzten Jahr",
"loginGuide": {
"f1": "Kostenlose Nutzung erhalten",
"f2": "Nachrichten auf mehreren Geräten synchronisieren",
"f3": "Überreiche Assistenten nutzen",
"f4": "Mächtige Plugins erkunden",
"title": "Nach dem Login kannst du:"
},
"messages": "Nachrichten",
"modelsRank": {
"left": "Modell",
Expand Down
7 changes: 7 additions & 0 deletions locales/en-US/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "No Data"
},
"lastYearActivity": "Activity in the past year",
"loginGuide": {
"f1": "Get free usage",
"f2": "Sync messages across devices",
"f3": "Access a wealth of assistants",
"f4": "Explore powerful plugins",
"title": "After logging in, you can:"
},
"messages": "Messages",
"modelsRank": {
"left": "Model",
Expand Down
7 changes: 7 additions & 0 deletions locales/es-ES/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Sin datos"
},
"lastYearActivity": "actividad en el último año",
"loginGuide": {
"f1": "Obtener uso gratuito",
"f2": "Sincronizar mensajes en múltiples dispositivos",
"f3": "Tener un asistente completo",
"f4": "Explorar potentes complementos",
"title": "Después de iniciar sesión, puedes:"
},
"messages": "Mensajes",
"modelsRank": {
"left": "Modelo",
Expand Down
7 changes: 7 additions & 0 deletions locales/fa-IR/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "داده‌ای وجود ندارد"
},
"lastYearActivity": "فعالیت در سال گذشته",
"loginGuide": {
"f1": "دریافت حجم رایگان",
"f2": "همگام‌سازی پیام‌ها در چند دستگاه",
"f3": "داشتن دستیارهای متنوع",
"f4": "کشف افزونه‌های قدرتمند",
"title": "پس از ورود می‌توانید:"
},
"messages": "پیام‌ها",
"modelsRank": {
"left": "مدل",
Expand Down
7 changes: 7 additions & 0 deletions locales/fr-FR/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Aucune donnée"
},
"lastYearActivity": "activité au cours de l'année dernière",
"loginGuide": {
"f1": "Obtenez un quota gratuit",
"f2": "Synchronisez les messages sur plusieurs appareils",
"f3": "Profitez d'un assistant riche",
"f4": "Explorez des plugins puissants",
"title": "Après vous être connecté, vous pouvez :"
},
"messages": "Messages",
"modelsRank": {
"left": "Modèle",
Expand Down
7 changes: 7 additions & 0 deletions locales/it-IT/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Nessun Dato"
},
"lastYearActivity": "attività nell'ultimo anno",
"loginGuide": {
"f1": "Ottieni un utilizzo gratuito",
"f2": "Sincronizza i messaggi su più dispositivi",
"f3": "Accedi a un ricco assistente",
"f4": "Esplora potenti plugin",
"title": "Dopo il login puoi:"
},
"messages": "Messaggi",
"modelsRank": {
"left": "Modello",
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "データなし"
},
"lastYearActivity": "過去1年間のアクティビティ",
"loginGuide": {
"f1": "無料の使用量を取得する",
"f2": "複数デバイスでメッセージを同期する",
"f3": "豊富なアシスタントを持つ",
"f4": "強力なプラグインを探索する",
"title": "ログイン後にできること:"
},
"messages": "メッセージ",
"modelsRank": {
"left": "モデル",
Expand Down
7 changes: 7 additions & 0 deletions locales/ko-KR/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "데이터 없음"
},
"lastYearActivity": "지난 1년간의 활동",
"loginGuide": {
"f1": "무료 사용량 받기",
"f2": "다양한 기기에서 메시지 동기화",
"f3": "풍부한 도우미 기능 제공",
"f4": "강력한 플러그인 탐색",
"title": "로그인 후 할 수 있는 것:"
},
"messages": "메시지",
"modelsRank": {
"left": "모델",
Expand Down
7 changes: 7 additions & 0 deletions locales/nl-NL/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Geen gegevens"
},
"lastYearActivity": "activiteit in het afgelopen jaar",
"loginGuide": {
"f1": "Krijg gratis gebruik",
"f2": "Synchroniseer berichten op meerdere apparaten",
"f3": "Geniet van een rijke assistent",
"f4": "Ontdek krachtige plugins",
"title": "Na inloggen kun je:"
},
"messages": "Berichten",
"modelsRank": {
"left": "Model",
Expand Down
7 changes: 7 additions & 0 deletions locales/pl-PL/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Brak danych"
},
"lastYearActivity": "aktywność w ciągu ostatniego roku",
"loginGuide": {
"f1": "Uzyskaj darmowy limit",
"f2": "Synchronizuj wiadomości na wielu urządzeniach",
"f3": "Skorzystaj z bogatego asystenta",
"f4": "Odkryj potężne wtyczki",
"title": "Po zalogowaniu możesz:"
},
"messages": "Wiadomości",
"modelsRank": {
"left": "Model",
Expand Down
7 changes: 7 additions & 0 deletions locales/pt-BR/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Sem Dados"
},
"lastYearActivity": "atividade no último ano",
"loginGuide": {
"f1": "Obter uso gratuito",
"f2": "Sincronizar mensagens em vários dispositivos",
"f3": "Ter assistentes ricos",
"f4": "Explorar poderosos plugins",
"title": "Após o login, você pode:"
},
"messages": "Mensagens",
"modelsRank": {
"left": "Modelo",
Expand Down
7 changes: 7 additions & 0 deletions locales/ru-RU/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Нет данных"
},
"lastYearActivity": "активность за последний год",
"loginGuide": {
"f1": "Получите бесплатный объем",
"f2": "Синхронизируйте сообщения на разных устройствах",
"f3": "Имеете доступ к богатым помощникам",
"f4": "Исследуйте мощные плагины",
"title": "После входа в систему вы можете:"
},
"messages": "Сообщения",
"modelsRank": {
"left": "Модель",
Expand Down
10 changes: 9 additions & 1 deletion locales/tr-TR/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Veri Yok"
},
"lastYearActivity": "geçen yılki aktivite",
"loginGuide": {
"f1": "Ücretsiz kullanım al",
"f2": "Çoklu cihazda mesaj senkronizasyonu",
"f3": "Zengin asistanlara sahip ol",
"f4": "Güçlü eklentileri keşfet",
"title": "Giriş yaptıktan sonra şunları yapabilirsiniz:"
},
"messages": "Mesajlar",
"modelsRank": {
"left": "Model",
Expand All @@ -69,7 +76,8 @@
"title": "Konu İçerik Sıralaması"
},
"updatedAt": "Güncellenme tarihi",
"welcome": "{{username}}, bu {{appName}} ile geçirdiğin <span>{{days}}</span> gün."
"welcome": "{{username}}, bu {{appName}} ile geçirdiğin <span>{{days}}</span> gün.",
"words": "Toplam kelime sayısı"
},
"tab": {
"profile": "Profil",
Expand Down
7 changes: 7 additions & 0 deletions locales/vi-VN/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "Không có dữ liệu"
},
"lastYearActivity": "hoạt động trong năm qua",
"loginGuide": {
"f1": "Nhận lượng sử dụng miễn phí",
"f2": "Đồng bộ tin nhắn trên nhiều thiết bị",
"f3": "Sở hữu trợ lý phong phú",
"f4": "Khám phá các plugin mạnh mẽ",
"title": "Sau khi đăng nhập, bạn có thể:"
},
"messages": "Tin nhắn",
"modelsRank": {
"left": "Mô hình",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh-CN/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "暂无数据"
},
"lastYearActivity": "过去一年活跃度",
"loginGuide": {
"f1": "获取免费用量",
"f2": "多端同步消息",
"f3": "拥有丰富助手",
"f4": "探索强大插件",
"title": "登陆后你可以:"
},
"messages": "消息数",
"modelsRank": {
"left": "模型名称",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh-TW/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
"title": "暫無數據"
},
"lastYearActivity": "過去一年活躍度",
"loginGuide": {
"f1": "獲取免費用量",
"f2": "多端同步消息",
"f3": "擁有豐富助手",
"f4": "探索強大插件",
"title": "登錄後你可以:"
},
"messages": "消息數",
"modelsRank": {
"left": "模型名稱",
Expand Down
4 changes: 2 additions & 2 deletions src/app/(main)/profile/stats/features/ModelsRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export const TopicsRank = memo(() => {
<BarList
data={data?.map((item) => mapData(item)) || []}
height={340}
leftLabel={t('stats.assistantsRank.left')}
leftLabel={t('stats.modelsRank.left')}
loading={isLoading || !data}
rightLabel={t('stats.assistantsRank.right')}
rightLabel={t('stats.modelsRank.right')}
/>
</Modal>
)}
Expand Down
7 changes: 4 additions & 3 deletions src/app/(main)/profile/stats/features/TopicsRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { FORM_STYLE } from '@/const/layoutTokens';
import { INBOX_SESSION_ID } from '@/const/session';
import { useClientDataSWR } from '@/libs/swr';
import { topicService } from '@/services/topic';
import { TopicRankItem } from '@/types/topic';
Expand All @@ -28,7 +29,7 @@ export const TopicsRank = memo(() => {
const mapData = (item: TopicRankItem) => {
const link = qs.stringifyUrl({
query: {
session: item.sessionId,
session: item.sessionId || INBOX_SESSION_ID,
topic: item.id,
},
url: '/chat',
Expand Down Expand Up @@ -89,10 +90,10 @@ export const TopicsRank = memo(() => {
<BarList
data={data?.map((item) => mapData(item)) || []}
height={340}
leftLabel={t('stats.assistantsRank.left')}
leftLabel={t('stats.topicsRank.left')}
loading={isLoading || !data}
onValueChange={(item) => router.push(item.link)}
rightLabel={t('stats.assistantsRank.right')}
rightLabel={t('stats.topicsRank.right')}
/>
</Modal>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/profile/stats/features/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Welcome = memo<{ mobile?: boolean }>(({ mobile }) => {
components={{
span:
isLoading || !data ? (
<Skeleton.Button active style={{ height: 24 }} />
<Skeleton.Button active style={{ height: 24, minWidth: 40, width: 40 }} />
) : (
<span style={{ fontWeight: 'bold' }} />
),
Expand Down
3 changes: 2 additions & 1 deletion src/database/server/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class SessionModel {
title: agents.title,
})
.from(sessions)
.where(and(eq(sessions.userId, this.userId)))
.leftJoin(topics, eq(sessions.id, topics.sessionId))
.leftJoin(agentsToSessions, eq(sessions.id, agentsToSessions.sessionId))
.leftJoin(agents, eq(agentsToSessions.agentId, agents.id))
Expand All @@ -146,7 +147,7 @@ export class SessionModel {
count: count(topics.id).as('count'),
})
.from(topics)
.where(isNull(topics.sessionId));
.where(and(eq(topics.userId, this.userId), isNull(topics.sessionId)));

const inboxCount = inboxResult[0].count;

Expand Down
1 change: 1 addition & 0 deletions src/database/server/models/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class TopicModel {
title: topics.title,
})
.from(topics)
.where(and(eq(topics.userId, this.userId)))
.leftJoin(messages, eq(topics.id, messages.topicId))
.groupBy(topics.id)
.orderBy(desc(sql`count`))
Expand Down
7 changes: 7 additions & 0 deletions src/locales/default/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export default {
title: '暂无数据',
},
lastYearActivity: '过去一年活跃度',
loginGuide: {
f1: '获取免费用量',
f2: '多端同步消息',
f3: '拥有丰富助手',
f4: '探索强大插件',
title: '登陆后你可以:',
},
messages: '消息数',
modelsRank: {
left: '模型名称',
Expand Down

0 comments on commit f3fdee7

Please sign in to comment.