From e2b7d80871e17885e04729d5e6d32bf4f1bab480 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 4 Jul 2024 00:08:21 +0200 Subject: [PATCH] [backend] Reset home timeline query heuristic after importing follows --- packages/backend/src/queue/processors/db/import-following.ts | 2 ++ .../backend/src/server/api/common/generate-following-query.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/queue/processors/db/import-following.ts b/packages/backend/src/queue/processors/db/import-following.ts index b1a7cd2c9..d58c71276 100644 --- a/packages/backend/src/queue/processors/db/import-following.ts +++ b/packages/backend/src/queue/processors/db/import-following.ts @@ -9,6 +9,7 @@ import { Users, DriveFiles } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; import { queueLogger } from "../../logger.js"; import type Bull from "bull"; +import { cache as heuristic } from "@/server/api/common/generate-following-query.js"; const logger = queueLogger.createSubLogger("import-following"); @@ -111,6 +112,7 @@ export async function importFollowing( } } + await heuristic.delete(user.id); logger.succ("Imported"); done(); } diff --git a/packages/backend/src/server/api/common/generate-following-query.ts b/packages/backend/src/server/api/common/generate-following-query.ts index 14835f7f5..c6a592d34 100644 --- a/packages/backend/src/server/api/common/generate-following-query.ts +++ b/packages/backend/src/server/api/common/generate-following-query.ts @@ -4,7 +4,7 @@ import { Followings, Notes } from "@/models/index.js"; import { Cache } from "@/misc/cache.js"; import { apiLogger } from "@/server/api/logger.js"; -const cache = new Cache("homeTlQueryData", 60 * 60 * 24); +export const cache = new Cache("homeTlQueryData", 60 * 60 * 24); const cutoff = 250; // 250 posts in the last 7 days, constant determined by comparing benchmarks for cutoff values between 100 and 2500 const logger = apiLogger.createSubLogger("heuristics");