From 6df1cec81a2969adb2643bed8a8b6d31efedfc6f Mon Sep 17 00:00:00 2001 From: mindset-tk Date: Wed, 6 Sep 2023 23:26:58 -0700 Subject: [PATCH 1/6] fix config.js "searchLimit" attribute --- src/preFilter.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/preFilter.ts b/src/preFilter.ts index 288847685..4e017497e 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -63,27 +63,30 @@ export function filterDupes(searchees: Searchee[]): Searchee[] { export async function filterTimestamps(searchee: Searchee): Promise { const { excludeOlder, excludeRecentSearch } = getRuntimeConfig(); const enabledIndexers = await getEnabledIndexers(); - const timestampDataSql = await db("searchee") + const timestampDataSql = await db("searchee") // @ts-expect-error crossJoin supports string .crossJoin("indexer") .leftOuterJoin("timestamp", { "timestamp.indexer_id": "indexer.id", "timestamp.searchee_id": "searchee.id", }) + .where("searchee.name", + searchee.name + ) .whereIn( "indexer.id", enabledIndexers.map((i) => i.id) ) - .max({ + .min({ first_searched_all: db.raw( "coalesce(timestamp.first_searched, 9223372036854775807)" ), }) - .min({ + .max({ last_searched_all: db.raw("coalesce(timestamp.last_searched, 0)"), }) .first(); - + const { first_searched_all, last_searched_all } = timestampDataSql; function logReason(reason) { logger.verbose({ From 5a603addd7fa7e8b52cf854e9d69d915073817bb Mon Sep 17 00:00:00 2001 From: mindset-tk Date: Wed, 6 Sep 2023 23:30:02 -0700 Subject: [PATCH 2/6] match tab formatting --- src/preFilter.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/preFilter.ts b/src/preFilter.ts index 4e017497e..b2add999c 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -63,16 +63,16 @@ export function filterDupes(searchees: Searchee[]): Searchee[] { export async function filterTimestamps(searchee: Searchee): Promise { const { excludeOlder, excludeRecentSearch } = getRuntimeConfig(); const enabledIndexers = await getEnabledIndexers(); - const timestampDataSql = await db("searchee") + const timestampDataSql = await db("searchee") // @ts-expect-error crossJoin supports string .crossJoin("indexer") .leftOuterJoin("timestamp", { "timestamp.indexer_id": "indexer.id", "timestamp.searchee_id": "searchee.id", }) - .where("searchee.name", - searchee.name - ) + .where("searchee.name", + searchee.name + ) .whereIn( "indexer.id", enabledIndexers.map((i) => i.id) @@ -86,7 +86,7 @@ export async function filterTimestamps(searchee: Searchee): Promise { last_searched_all: db.raw("coalesce(timestamp.last_searched, 0)"), }) .first(); - + const { first_searched_all, last_searched_all } = timestampDataSql; function logReason(reason) { logger.verbose({ From d5a90ad8c2f66880029fd59587449ff2346c1e7f Mon Sep 17 00:00:00 2001 From: mindset-tk Date: Thu, 7 Sep 2023 08:56:48 -0700 Subject: [PATCH 3/6] Also fixes cross-seed/cross-seed/#402 --- src/preFilter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preFilter.ts b/src/preFilter.ts index b2add999c..d36c6dc57 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -82,7 +82,7 @@ export async function filterTimestamps(searchee: Searchee): Promise { "coalesce(timestamp.first_searched, 9223372036854775807)" ), }) - .max({ + .min({ last_searched_all: db.raw("coalesce(timestamp.last_searched, 0)"), }) .first(); From 1576ce4642218a204d7b7dd5e925b84ea2bf02be Mon Sep 17 00:00:00 2001 From: Michael Goodnow Date: Sun, 10 Sep 2023 23:35:47 -0400 Subject: [PATCH 4/6] Update src/preFilter.ts --- src/preFilter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/preFilter.ts b/src/preFilter.ts index d36c6dc57..20422d03a 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -86,7 +86,6 @@ export async function filterTimestamps(searchee: Searchee): Promise { last_searched_all: db.raw("coalesce(timestamp.last_searched, 0)"), }) .first(); - const { first_searched_all, last_searched_all } = timestampDataSql; function logReason(reason) { logger.verbose({ From 021f6fcbacb349d9b496e32be73e61db106cda44 Mon Sep 17 00:00:00 2001 From: Michael Goodnow Date: Sun, 10 Sep 2023 23:36:10 -0400 Subject: [PATCH 5/6] Update src/preFilter.ts --- src/preFilter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/preFilter.ts b/src/preFilter.ts index 20422d03a..87a20f9ce 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -86,6 +86,7 @@ export async function filterTimestamps(searchee: Searchee): Promise { last_searched_all: db.raw("coalesce(timestamp.last_searched, 0)"), }) .first(); + const { first_searched_all, last_searched_all } = timestampDataSql; function logReason(reason) { logger.verbose({ From ed08bfc218981b38c9eee30677b0a18f1229c732 Mon Sep 17 00:00:00 2001 From: mindset-tk Date: Mon, 11 Sep 2023 08:58:56 -0700 Subject: [PATCH 6/6] var name update --- src/preFilter.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/preFilter.ts b/src/preFilter.ts index 87a20f9ce..544847061 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -78,7 +78,7 @@ export async function filterTimestamps(searchee: Searchee): Promise { enabledIndexers.map((i) => i.id) ) .min({ - first_searched_all: db.raw( + first_searched_any: db.raw( "coalesce(timestamp.first_searched, 9223372036854775807)" ), }) @@ -87,7 +87,7 @@ export async function filterTimestamps(searchee: Searchee): Promise { }) .first(); - const { first_searched_all, last_searched_all } = timestampDataSql; + const { first_searched_any, last_searched_all } = timestampDataSql; function logReason(reason) { logger.verbose({ label: Label.PREFILTER, @@ -97,12 +97,12 @@ export async function filterTimestamps(searchee: Searchee): Promise { if ( typeof excludeOlder === "number" && - first_searched_all && - first_searched_all < nMsAgo(excludeOlder) + first_searched_any && + first_searched_any < nMsAgo(excludeOlder) ) { logReason( `its first search timestamp ${humanReadable( - first_searched_all + first_searched_any )} is older than ${ms(excludeOlder, { long: true })} ago` ); return false;