Restrict matched users to last 24h

This commit is contained in:
MartinBraquet
2025-09-16 18:09:48 +02:00
parent 0447b22dd2
commit fefa261e7d
2 changed files with 6 additions and 2 deletions

View File

@@ -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)
)

View File

@@ -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'}