Skip to content

Commit

Permalink
perf:reduce transactionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou committed Jul 10, 2024
1 parent 0944ee6 commit 29d0d5a
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 263 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- CreateTable
CREATE TABLE "EventLog" (
"uid" UUID NOT NULL DEFAULT gen_random_uuid(),
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"eventName" STRING NOT NULL,
"data" STRING NOT NULL,

CONSTRAINT "EventLog_pkey" PRIMARY KEY ("uid")
);
14 changes: 11 additions & 3 deletions frontend/desktop/prisma/global/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ model Account {
}

model AccountTransaction {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
type String
userUid String @db.Uuid
userUid String @db.Uuid
deduction_balance BigInt
balance BigInt
message String?
created_at DateTime @default(now()) @db.Timestamptz(3)
updated_at DateTime @default(now()) @db.Timestamptz(3)
billing_id String @db.Uuid
billing_id String @db.Uuid
}

model ErrorPaymentCreate {
Expand Down Expand Up @@ -209,6 +209,14 @@ model AuditLogDetail {
auditLog AuditLog @relation(fields: [auditLogUid], references: [uid])
}

model EventLog {
uid String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @db.Timestamptz(3)
eventName String
// json
data String
}

model InviteReward {
payment_id String @id
userUid String @db.Uuid
Expand Down
9 changes: 9 additions & 0 deletions frontend/desktop/src/services/backend/cronjob/deleteUserCr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export class DeleteUserCrJob implements CronJobStatus {
userUid
}
}),
globalPrisma.eventLog.create({
data: {
eventName: 'DELETE_USER',
data: JSON.stringify({
userUid,
message: `delete user success`
})
}
}),
globalPrisma.precommitTransaction.findUniqueOrThrow({
where: {
uid: this.transactionUid,
Expand Down
Loading

0 comments on commit 29d0d5a

Please sign in to comment.