|
|
|
@ -51,8 +51,14 @@ Extract new facts from these messages.`;
|
|
|
|
|
export const facts = router({
|
|
|
|
|
fetchByConversationId: publicProcedure
|
|
|
|
|
.input((x) => x as { conversationId: string })
|
|
|
|
|
.query(async ({ input: { conversationId }, ctx: { db } }) => {
|
|
|
|
|
return await db.facts.findByConversationId(conversationId);
|
|
|
|
|
.query(async ({ input: { conversationId }, ctx: { dbClient } }) => {
|
|
|
|
|
const rows = await dbClient
|
|
|
|
|
.selectFrom("facts")
|
|
|
|
|
.innerJoin("messages", "messages.id", "facts.sourceMessageId")
|
|
|
|
|
.selectAll("facts")
|
|
|
|
|
.where("conversationId", "=", conversationId)
|
|
|
|
|
.execute();
|
|
|
|
|
return rows;
|
|
|
|
|
}),
|
|
|
|
|
deleteOne: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
@ -61,8 +67,8 @@ export const facts = router({
|
|
|
|
|
factId: string;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.mutation(async ({ input: { factId }, ctx: { db } }) => {
|
|
|
|
|
await db.facts.delete(factId);
|
|
|
|
|
.mutation(async ({ input: { factId }, ctx: { dbClient } }) => {
|
|
|
|
|
await dbClient.deleteFrom("facts").where("id", "=", factId).execute();
|
|
|
|
|
return { ok: true };
|
|
|
|
|
}),
|
|
|
|
|
update: publicProcedure
|
|
|
|
@ -73,8 +79,12 @@ export const facts = router({
|
|
|
|
|
content: string;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.mutation(async ({ input: { factId, content }, ctx: { db } }) => {
|
|
|
|
|
await db.facts.update(factId, { content });
|
|
|
|
|
.mutation(async ({ input: { factId, content }, ctx: { dbClient } }) => {
|
|
|
|
|
await dbClient
|
|
|
|
|
.updateTable("facts")
|
|
|
|
|
.set({ content })
|
|
|
|
|
.where("id", "=", factId)
|
|
|
|
|
.execute();
|
|
|
|
|
return { ok: true };
|
|
|
|
|
}),
|
|
|
|
|
extractFromNewMessages: publicProcedure
|
|
|
|
|