From c0a686b565a702f6b1f89489fa8c45616c506fee Mon Sep 17 00:00:00 2001 From: matty Date: Sun, 29 Jun 2025 15:25:50 -0400 Subject: [PATCH] update schema and prompt structure --- .../migration.sql | 17 +++++++++++++++++ prisma/schema.prisma | 2 +- src/main.ts | 5 +++-- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20250629191541_database_handles_insertion_time/migration.sql diff --git a/prisma/migrations/20250629191541_database_handles_insertion_time/migration.sql b/prisma/migrations/20250629191541_database_handles_insertion_time/migration.sql new file mode 100644 index 0000000..4966bab --- /dev/null +++ b/prisma/migrations/20250629191541_database_handles_insertion_time/migration.sql @@ -0,0 +1,17 @@ +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Response" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "pleromaNotificationId" TEXT NOT NULL DEFAULT 'null', + "to" TEXT NOT NULL, + "request" TEXT, + "response" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "processedAt" DATETIME +); +INSERT INTO "new_Response" ("createdAt", "id", "pleromaNotificationId", "processedAt", "request", "response", "to") SELECT coalesce("createdAt", CURRENT_TIMESTAMP) AS "createdAt", "id", "pleromaNotificationId", "processedAt", "request", "response", "to" FROM "Response"; +DROP TABLE "Response"; +ALTER TABLE "new_Response" RENAME TO "Response"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d60dc89..574f186 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -17,7 +17,7 @@ model Response { to String request String? response String? - createdAt DateTime? + createdAt DateTime @default(now()) processedAt DateTime? } diff --git a/src/main.ts b/src/main.ts index ef77e2d..95dc74c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -72,10 +72,11 @@ const storePromptData = async ( await prisma.response.create({ data: { response: ollamaResponseBody.response, - request: striptags(notification.status.content), + request: `${notification.status.account.fqn} asks: ${striptags( + notification.status.content + )}`, to: notification.account.fqn, pleromaNotificationId: notification.status.id, - createdAt: new Date(Date.now()), }, }); } catch (error: any) {