Skip to content

Commit

Permalink
feat: adding new columns and storing requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn committed Aug 25, 2024
1 parent 11b2193 commit e06f7d9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions apps/vectorize/migrations/0003_update_item.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Update item with new text and metadata columns
ALTER TABLE "item"
ADD COLUMN "text" varchar(2024) NULL;

ALTER TABLE "item"
ADD COLUMN "metadata" varchar(2024) NULL;
2 changes: 1 addition & 1 deletion apps/vectorize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"wrangler": "wrangler",
"db:init": "npx wrangler d1 migrations create llm-rss-vectorise-agent init",
"db:migrate": "npx wrangler d1 migrations apply llm-rss-vectorise-agent",
"db:prisma:migrate": "npx prisma migrate diff --script --from-empty --to-schema-datamodel ./prisma/schema.prisma",
"db:prisma:migrate": "npx prisma migrate diff --script --from-schema-datamodel ./prisma/schema.prisma --to-migrations ./prisma/migrations",
"db:prisma:generate": "npx prisma generate"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions apps/vectorize/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ model item {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status String
text String?
metadata String?
}
21 changes: 20 additions & 1 deletion apps/vectorize/src/handlers/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,20 @@ async function processRSSMessage(
id: entryId,
data: { text: parsedString, metadata },
});
await updateItemStatus(prisma, entryId, 'queued');
await prisma.item.upsert({
where: { id },
update: {
status: 'queued',
text: parsedString,
metadata: JSON.stringify(metadata),
},
create: {
id,
status: 'queued',
text: parsedString,
metadata: JSON.stringify(metadata),
},
});

inserted.push({ id: entryId, status: 'queued' });
}
Expand Down Expand Up @@ -157,6 +170,12 @@ async function processEntryMessage(
return null;
}

await prisma.item.upsert({
where: { id },
update: { status: 'queued' },
create: { id, status: 'queued' },
});

let queryText = parsedString;
// TODO: Make this work, getting error: "Protocol error (Runtime.callFunctionOn): Argument should belong to the same JavaScript world as target object"
/* if (metadata.url && env.BROWSER) {
Expand Down

0 comments on commit e06f7d9

Please sign in to comment.