Skip to content

Commit

Permalink
🐛 fix: Fix heatmap and manifest (lobehub#5289)
Browse files Browse the repository at this point in the history
* 🐛 fix: Fix heatmap and manifest

* 📝 docs: Update changelog

* ✅ test: Fix test

* ✅ test: Fix test

* ✅ test: Fix test
  • Loading branch information
canisminor1990 authored Jan 4, 2025
1 parent 0280c1d commit 3973249
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"$schema": "https://github.com/lobehub/lobe-chat/blob/main/docs/changelog/schema.json",
"cloud": [],
"community": [
{
"image": "https://github.com/user-attachments/assets/3d80e0f5-d32a-4412-85b2-e709731460a0",
"id": "2025-01-03-user-profile",
"date": "2025-01-03",
"versionRange": ["1.43.0", "1.43.1"]
},
{
"image": "https://github.com/user-attachments/assets/2048b4c2-4a56-4029-acf9-71e35ff08652",
"id": "2024-11-27-forkable-chat",
Expand Down
7 changes: 2 additions & 5 deletions src/app/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import type { MetadataRoute } from 'next';

import { BRANDING_LOGO_URL, BRANDING_NAME } from '@/const/branding';
import { manifestModule } from '@/server/manifest';
import { translation } from '@/server/translation';

const manifest = async (): Promise<MetadataRoute.Manifest | any> => {
const { t } = await translation('metadata');

const manifest = (): MetadataRoute.Manifest | any => {
return manifestModule.generate({
description: t('chat.description', { appName: BRANDING_NAME }),
description: `${BRANDING_NAME} brings you the best UI experience for ChatGPT, Claude, Gemini, and OLLaMA.`,
icons: [
{
purpose: 'any',
Expand Down
12 changes: 6 additions & 6 deletions src/database/server/models/__tests__/message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,14 +1278,14 @@ describe('MessageModel', () => {
(item) => item.date === today.subtract(2, 'day').format('YYYY-MM-DD'),
);
expect(twoDaysAgo?.count).toBe(2);
expect(twoDaysAgo?.level).toBe(0);
expect(twoDaysAgo?.level).toBe(1);

// 检查一天前的数据
const oneDayAgo = result.find(
(item) => item.date === today.subtract(1, 'day').format('YYYY-MM-DD'),
);
expect(oneDayAgo?.count).toBe(1);
expect(oneDayAgo?.level).toBe(0);
expect(oneDayAgo?.level).toBe(1);

// 检查今天的数据
const todayData = result.find((item) => item.date === today.format('YYYY-MM-DD'));
Expand Down Expand Up @@ -1356,25 +1356,25 @@ describe('MessageModel', () => {
(item) => item.date === today.subtract(4, 'day').format('YYYY-MM-DD'),
);
expect(fourDaysAgo?.count).toBe(1);
expect(fourDaysAgo?.level).toBe(0);
expect(fourDaysAgo?.level).toBe(1);

const threeDaysAgo = result.find(
(item) => item.date === today.subtract(3, 'day').format('YYYY-MM-DD'),
);
expect(threeDaysAgo?.count).toBe(6);
expect(threeDaysAgo?.level).toBe(1);
expect(threeDaysAgo?.level).toBe(2);

const twoDaysAgo = result.find(
(item) => item.date === today.subtract(2, 'day').format('YYYY-MM-DD'),
);
expect(twoDaysAgo?.count).toBe(11);
expect(twoDaysAgo?.level).toBe(2);
expect(twoDaysAgo?.level).toBe(3);

const oneDayAgo = result.find(
(item) => item.date === today.subtract(1, 'day').format('YYYY-MM-DD'),
);
expect(oneDayAgo?.count).toBe(16);
expect(oneDayAgo?.level).toBe(3);
expect(oneDayAgo?.level).toBe(4);

const todayData = result.find((item) => item.date === today.format('YYYY-MM-DD'));
expect(todayData?.count).toBe(21);
Expand Down
2 changes: 1 addition & 1 deletion src/database/server/models/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export class MessageModel {
);

const count = matchingResult ? matchingResult.count : 0;
const levelCount = count > 0 ? Math.floor(count / 5) : 0;
const levelCount = count > 0 ? Math.ceil(count / 5) : 0;
const level = levelCount > 4 ? 4 : levelCount;

heatmapData.push({
Expand Down

0 comments on commit 3973249

Please sign in to comment.