From 816b8d67c32b53df7278657493dd3dc8755dac68 Mon Sep 17 00:00:00 2001 From: "ebwinters@comcast.net" Date: Mon, 11 Dec 2023 11:28:45 -0800 Subject: [PATCH] algo actually checks alf --- src/algos/whats-alf.ts | 1 + src/db/migrations.ts | 1 + src/subscription.ts | 5 +---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/algos/whats-alf.ts b/src/algos/whats-alf.ts index a131547e1..8a5c8f45d 100644 --- a/src/algos/whats-alf.ts +++ b/src/algos/whats-alf.ts @@ -23,6 +23,7 @@ export const handler = async (ctx: AppContext, params: QueryParams) => { .where('post.indexedAt', '<', timeStr) .orWhere((qb) => qb.where('post.indexedAt', '=', timeStr)) .where('post.cid', '<', cid) + .where('post.postText', 'like', '%alf%') } const res = await builder.execute() diff --git a/src/db/migrations.ts b/src/db/migrations.ts index 966007801..df91563df 100644 --- a/src/db/migrations.ts +++ b/src/db/migrations.ts @@ -17,6 +17,7 @@ migrations['001'] = { .addColumn('replyParent', 'varchar') .addColumn('replyRoot', 'varchar') .addColumn('indexedAt', 'varchar', (col) => col.notNull()) + .addColumn('postText', 'varchar') .execute() await db.schema .createTable('sub_state') diff --git a/src/subscription.ts b/src/subscription.ts index b3a141e8d..83c3f66cf 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -18,10 +18,6 @@ export class FirehoseSubscription extends FirehoseSubscriptionBase { const postsToDelete = ops.posts.deletes.map((del) => del.uri) const postsToCreate = ops.posts.creates - .filter((create) => { - // only alf-related posts - return create.record.text.toLowerCase().includes('alf') - }) .map((create) => { // map alf-related posts to a db row return { @@ -30,6 +26,7 @@ export class FirehoseSubscription extends FirehoseSubscriptionBase { replyParent: create.record?.reply?.parent.uri ?? null, replyRoot: create.record?.reply?.root.uri ?? null, indexedAt: new Date().toISOString(), + postText: create.record.text.toLowerCase() } })