From fefa261e7d8395415e9fd2243d4068bb6611051d Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 16 Sep 2025 18:09:48 +0200 Subject: [PATCH] Restrict matched users to last 24h --- backend/api/src/get-profiles.ts | 4 ++++ backend/api/src/send-search-notifications.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/api/src/get-profiles.ts b/backend/api/src/get-profiles.ts index c4ff4fbb..ca2110cc 100644 --- a/backend/api/src/get-profiles.ts +++ b/backend/api/src/get-profiles.ts @@ -23,6 +23,7 @@ export type profileQueryType = { compatibleWithUserId?: string | undefined, skipId?: string | undefined, orderBy?: string | undefined, + lastModificationWithin?: string | undefined, } @@ -44,6 +45,7 @@ export const loadProfiles = async (props: profileQueryType) => { geodbCityIds, compatibleWithUserId, orderBy: orderByParam = 'created_time', + lastModificationWithin, skipId, } = props @@ -151,6 +153,8 @@ export const loadProfiles = async (props: profileQueryType) => { {after} ), + lastModificationWithin && where(`last_modification_time >= NOW() - INTERVAL $(lastModificationWithin)`, {lastModificationWithin}), + limitParam && limit(limitParam) ) diff --git a/backend/api/src/send-search-notifications.ts b/backend/api/src/send-search-notifications.ts index fcb8ce1a..7fa077d1 100644 --- a/backend/api/src/send-search-notifications.ts +++ b/backend/api/src/send-search-notifications.ts @@ -53,7 +53,7 @@ export const sendSearchNotifications = async () => { for (const row of searches) { if (typeof row.search_filters !== 'object') continue; - const props = {...row.search_filters, skipId: row.creator_id} + const props = {...row.search_filters, skipId: row.creator_id, lastModificationWithin: '24 hours'} const profiles = await loadProfiles(props as profileQueryType) console.log(profiles.map((item: any) => item.name)) if (!profiles.length) continue @@ -74,7 +74,7 @@ export const sendSearchNotifications = async () => { })), }) } - console.log(JSON.stringify(matches, null, 2)) + console.log('matches:', JSON.stringify(matches, null, 2)) await notifyBookmarkedSearch(matches) return {status: 'success'}