From 029f67b7e545188351504afbef7e4ac7c5fadb94 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 18 Feb 2025 20:47:48 +0000 Subject: [PATCH 1/2] fix time zone for CustomEmojiService test otherwise, the timestamps that the test uses for queries are interpreted as UTC (because they have a TZ in the string), but the truncated date is interpreted in the session timezone, which defaults to the server timezone, which can be anything thanks to @fEmber for noticing --- packages/backend/test/unit/CustomEmojiService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend/test/unit/CustomEmojiService.ts b/packages/backend/test/unit/CustomEmojiService.ts index ffd96356e0..8c3dac69e8 100644 --- a/packages/backend/test/unit/CustomEmojiService.ts +++ b/packages/backend/test/unit/CustomEmojiService.ts @@ -17,6 +17,7 @@ import { EmojisRepository } from '@/models/_.js'; import { MiEmoji } from '@/models/Emoji.js'; import { CoreModule } from '@/core/CoreModule.js'; import { DriveService } from '@/core//DriveService.js'; +import { DataSource } from 'typeorm'; describe('CustomEmojiService', () => { let app: TestingModule; @@ -48,6 +49,7 @@ describe('CustomEmojiService', () => { service = app.get(CustomEmojiService); emojisRepository = app.get(DI.emojisRepository); idService = app.get(IdService); + await app.get(DI.db).query("set session time zone 'UTC'"); }); describe('fetchEmojis', () => { From 9e3667b2a3c2c73185d5dc511568b20d5f477444 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 18 Feb 2025 20:49:36 +0000 Subject: [PATCH 2/2] fix names that annoy @dakkar --- packages/backend/src/core/CustomEmojiService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index 165d58d1b2..2e4eddf797 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -520,11 +520,11 @@ export class CustomEmojiService implements OnApplicationShutdown { const q = params.query; if (q.updatedAtFrom) { // noIndexScan - builder.andWhere('CAST(emoji.updatedAt AS DATE) >= :updateAtFrom', { updateAtFrom: q.updatedAtFrom }); + builder.andWhere('CAST(emoji.updatedAt AS DATE) >= :updatedAtFrom', { updatedAtFrom: q.updatedAtFrom }); } if (q.updatedAtTo) { // noIndexScan - builder.andWhere('CAST(emoji.updatedAt AS DATE) <= :updateAtTo', { updateAtTo: q.updatedAtTo }); + builder.andWhere('CAST(emoji.updatedAt AS DATE) <= :updatedAtTo', { updatedAtTo: q.updatedAtTo }); } if (q.name) { builder.andWhere('emoji.name ~~ ANY(ARRAY[:...name])', { name: multipleWordsToQuery(q.name) });