From f3fdee75a5606b1951f27bf0bc258356b7925c18 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Sat, 4 Jan 2025 01:26:39 +0800 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=90=9B=20fix:=20fix=20stats=20data=20q?= =?UTF-8?q?uery=20issue=20(#5283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update locale * fix: fix user id query * fix * fix modal text --- locales/ar/auth.json | 7 +++++++ locales/bg-BG/auth.json | 7 +++++++ locales/de-DE/auth.json | 7 +++++++ locales/en-US/auth.json | 7 +++++++ locales/es-ES/auth.json | 7 +++++++ locales/fa-IR/auth.json | 7 +++++++ locales/fr-FR/auth.json | 7 +++++++ locales/it-IT/auth.json | 7 +++++++ locales/ja-JP/auth.json | 7 +++++++ locales/ko-KR/auth.json | 7 +++++++ locales/nl-NL/auth.json | 7 +++++++ locales/pl-PL/auth.json | 7 +++++++ locales/pt-BR/auth.json | 7 +++++++ locales/ru-RU/auth.json | 7 +++++++ locales/tr-TR/auth.json | 10 +++++++++- locales/vi-VN/auth.json | 7 +++++++ locales/zh-CN/auth.json | 7 +++++++ locales/zh-TW/auth.json | 7 +++++++ src/app/(main)/profile/stats/features/ModelsRank.tsx | 4 ++-- src/app/(main)/profile/stats/features/TopicsRank.tsx | 7 ++++--- src/app/(main)/profile/stats/features/Welcome.tsx | 2 +- src/database/server/models/session.ts | 3 ++- src/database/server/models/topic.ts | 1 + src/locales/default/auth.ts | 7 +++++++ 24 files changed, 145 insertions(+), 8 deletions(-) diff --git a/locales/ar/auth.json b/locales/ar/auth.json index 3d194cd4edf7f..f9c3f5cb717da 100644 --- a/locales/ar/auth.json +++ b/locales/ar/auth.json @@ -53,6 +53,13 @@ "title": "لا توجد بيانات" }, "lastYearActivity": "النشاط في العام الماضي", + "loginGuide": { + "f1": "احصل على استخدام مجاني", + "f2": "مزامنة الرسائل عبر الأجهزة المتعددة", + "f3": "تمتع بمساعدين متنوعين", + "f4": "استكشف الإضافات القوية", + "title": "بعد تسجيل الدخول يمكنك:" + }, "messages": "رسائل", "modelsRank": { "left": "النموذج", diff --git a/locales/bg-BG/auth.json b/locales/bg-BG/auth.json index 28f68c11fe195..351f00fcf2849 100644 --- a/locales/bg-BG/auth.json +++ b/locales/bg-BG/auth.json @@ -53,6 +53,13 @@ "title": "Няма данни" }, "lastYearActivity": "активност през последната година", + "loginGuide": { + "f1": "Получете безплатен лимит", + "f2": "Синхронизирайте съобщения на множество устройства", + "f3": "Разполагайте с богат асистент", + "f4": "Изследвайте мощни приставки", + "title": "След влизане можете да:" + }, "messages": "Съобщения", "modelsRank": { "left": "Модел", diff --git a/locales/de-DE/auth.json b/locales/de-DE/auth.json index 425c27c70a229..457bd83acabf3 100644 --- a/locales/de-DE/auth.json +++ b/locales/de-DE/auth.json @@ -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", diff --git a/locales/en-US/auth.json b/locales/en-US/auth.json index dc14c3d13ca80..b879a175c6c6e 100644 --- a/locales/en-US/auth.json +++ b/locales/en-US/auth.json @@ -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", diff --git a/locales/es-ES/auth.json b/locales/es-ES/auth.json index afe4820f1eeb0..87cda58774978 100644 --- a/locales/es-ES/auth.json +++ b/locales/es-ES/auth.json @@ -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", diff --git a/locales/fa-IR/auth.json b/locales/fa-IR/auth.json index 36d9ce6836815..abe4e7efc6514 100644 --- a/locales/fa-IR/auth.json +++ b/locales/fa-IR/auth.json @@ -53,6 +53,13 @@ "title": "داده‌ای وجود ندارد" }, "lastYearActivity": "فعالیت در سال گذشته", + "loginGuide": { + "f1": "دریافت حجم رایگان", + "f2": "همگام‌سازی پیام‌ها در چند دستگاه", + "f3": "داشتن دستیارهای متنوع", + "f4": "کشف افزونه‌های قدرتمند", + "title": "پس از ورود می‌توانید:" + }, "messages": "پیام‌ها", "modelsRank": { "left": "مدل", diff --git a/locales/fr-FR/auth.json b/locales/fr-FR/auth.json index 8d46b46675b6e..28f044071849f 100644 --- a/locales/fr-FR/auth.json +++ b/locales/fr-FR/auth.json @@ -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", diff --git a/locales/it-IT/auth.json b/locales/it-IT/auth.json index 9bdf693376464..92b84267f5d1a 100644 --- a/locales/it-IT/auth.json +++ b/locales/it-IT/auth.json @@ -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", diff --git a/locales/ja-JP/auth.json b/locales/ja-JP/auth.json index bd3ac04b3b9ad..24453dc45f42e 100644 --- a/locales/ja-JP/auth.json +++ b/locales/ja-JP/auth.json @@ -53,6 +53,13 @@ "title": "データなし" }, "lastYearActivity": "過去1年間のアクティビティ", + "loginGuide": { + "f1": "無料の使用量を取得する", + "f2": "複数デバイスでメッセージを同期する", + "f3": "豊富なアシスタントを持つ", + "f4": "強力なプラグインを探索する", + "title": "ログイン後にできること:" + }, "messages": "メッセージ", "modelsRank": { "left": "モデル", diff --git a/locales/ko-KR/auth.json b/locales/ko-KR/auth.json index 90b3249577352..7c3abc8cfae13 100644 --- a/locales/ko-KR/auth.json +++ b/locales/ko-KR/auth.json @@ -53,6 +53,13 @@ "title": "데이터 없음" }, "lastYearActivity": "지난 1년간의 활동", + "loginGuide": { + "f1": "무료 사용량 받기", + "f2": "다양한 기기에서 메시지 동기화", + "f3": "풍부한 도우미 기능 제공", + "f4": "강력한 플러그인 탐색", + "title": "로그인 후 할 수 있는 것:" + }, "messages": "메시지", "modelsRank": { "left": "모델", diff --git a/locales/nl-NL/auth.json b/locales/nl-NL/auth.json index 0c678d879dd6b..0b65ab84e2072 100644 --- a/locales/nl-NL/auth.json +++ b/locales/nl-NL/auth.json @@ -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", diff --git a/locales/pl-PL/auth.json b/locales/pl-PL/auth.json index 9bd4b95c33b17..b589dff7d2312 100644 --- a/locales/pl-PL/auth.json +++ b/locales/pl-PL/auth.json @@ -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", diff --git a/locales/pt-BR/auth.json b/locales/pt-BR/auth.json index 17697ffdbc676..442a5863b0cab 100644 --- a/locales/pt-BR/auth.json +++ b/locales/pt-BR/auth.json @@ -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", diff --git a/locales/ru-RU/auth.json b/locales/ru-RU/auth.json index fd65a1df4c7b8..3229b1a077177 100644 --- a/locales/ru-RU/auth.json +++ b/locales/ru-RU/auth.json @@ -53,6 +53,13 @@ "title": "Нет данных" }, "lastYearActivity": "активность за последний год", + "loginGuide": { + "f1": "Получите бесплатный объем", + "f2": "Синхронизируйте сообщения на разных устройствах", + "f3": "Имеете доступ к богатым помощникам", + "f4": "Исследуйте мощные плагины", + "title": "После входа в систему вы можете:" + }, "messages": "Сообщения", "modelsRank": { "left": "Модель", diff --git a/locales/tr-TR/auth.json b/locales/tr-TR/auth.json index 6b63eeadab563..f85170a90d9d4 100644 --- a/locales/tr-TR/auth.json +++ b/locales/tr-TR/auth.json @@ -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", @@ -69,7 +76,8 @@ "title": "Konu İçerik Sıralaması" }, "updatedAt": "Güncellenme tarihi", - "welcome": "{{username}}, bu {{appName}} ile geçirdiğin {{days}} gün." + "welcome": "{{username}}, bu {{appName}} ile geçirdiğin {{days}} gün.", + "words": "Toplam kelime sayısı" }, "tab": { "profile": "Profil", diff --git a/locales/vi-VN/auth.json b/locales/vi-VN/auth.json index f019732dbe68d..9b42bad706419 100644 --- a/locales/vi-VN/auth.json +++ b/locales/vi-VN/auth.json @@ -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", diff --git a/locales/zh-CN/auth.json b/locales/zh-CN/auth.json index f3ab6379f912f..422463902c045 100644 --- a/locales/zh-CN/auth.json +++ b/locales/zh-CN/auth.json @@ -53,6 +53,13 @@ "title": "暂无数据" }, "lastYearActivity": "过去一年活跃度", + "loginGuide": { + "f1": "获取免费用量", + "f2": "多端同步消息", + "f3": "拥有丰富助手", + "f4": "探索强大插件", + "title": "登陆后你可以:" + }, "messages": "消息数", "modelsRank": { "left": "模型名称", diff --git a/locales/zh-TW/auth.json b/locales/zh-TW/auth.json index 27137eb6d5186..c0c29a8ee6705 100644 --- a/locales/zh-TW/auth.json +++ b/locales/zh-TW/auth.json @@ -53,6 +53,13 @@ "title": "暫無數據" }, "lastYearActivity": "過去一年活躍度", + "loginGuide": { + "f1": "獲取免費用量", + "f2": "多端同步消息", + "f3": "擁有豐富助手", + "f4": "探索強大插件", + "title": "登錄後你可以:" + }, "messages": "消息數", "modelsRank": { "left": "模型名稱", diff --git a/src/app/(main)/profile/stats/features/ModelsRank.tsx b/src/app/(main)/profile/stats/features/ModelsRank.tsx index 6cef148190361..4ec8c7959a6f4 100644 --- a/src/app/(main)/profile/stats/features/ModelsRank.tsx +++ b/src/app/(main)/profile/stats/features/ModelsRank.tsx @@ -71,9 +71,9 @@ export const TopicsRank = memo(() => { 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')} /> )} diff --git a/src/app/(main)/profile/stats/features/TopicsRank.tsx b/src/app/(main)/profile/stats/features/TopicsRank.tsx index 65151a2bd4e75..2b4d3248c7b2c 100644 --- a/src/app/(main)/profile/stats/features/TopicsRank.tsx +++ b/src/app/(main)/profile/stats/features/TopicsRank.tsx @@ -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'; @@ -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', @@ -89,10 +90,10 @@ export const TopicsRank = memo(() => { 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')} /> )} diff --git a/src/app/(main)/profile/stats/features/Welcome.tsx b/src/app/(main)/profile/stats/features/Welcome.tsx index 0706e27c9873b..0935fbbe90f1c 100644 --- a/src/app/(main)/profile/stats/features/Welcome.tsx +++ b/src/app/(main)/profile/stats/features/Welcome.tsx @@ -49,7 +49,7 @@ const Welcome = memo<{ mobile?: boolean }>(({ mobile }) => { components={{ span: isLoading || !data ? ( - + ) : ( ), diff --git a/src/database/server/models/session.ts b/src/database/server/models/session.ts index 0b8da2b504233..f7a3c0afde580 100644 --- a/src/database/server/models/session.ts +++ b/src/database/server/models/session.ts @@ -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)) @@ -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; diff --git a/src/database/server/models/topic.ts b/src/database/server/models/topic.ts index ab730351fb8ed..7c7f757219cf8 100644 --- a/src/database/server/models/topic.ts +++ b/src/database/server/models/topic.ts @@ -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`)) diff --git a/src/locales/default/auth.ts b/src/locales/default/auth.ts index 0dbc38e7b09ea..e5dc7f8080492 100644 --- a/src/locales/default/auth.ts +++ b/src/locales/default/auth.ts @@ -53,6 +53,13 @@ export default { title: '暂无数据', }, lastYearActivity: '过去一年活跃度', + loginGuide: { + f1: '获取免费用量', + f2: '多端同步消息', + f3: '拥有丰富助手', + f4: '探索强大插件', + title: '登陆后你可以:', + }, messages: '消息数', modelsRank: { left: '模型名称',