Skip to content

Commit

Permalink
Added scout quest model (#388)
Browse files Browse the repository at this point in the history
* Added scout quest model

* ci: version bump to 0.93.2-rc-feat-sg-quest-p.0

* Daily claim enum builder event type

* ci: version bump to 0.93.2-rc-feat-sg-quest-p.1

* Added daily claim event

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.0

* Made telegramid big int

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.1

* Added scout social quest model

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.2

* Added completed at to scout social quest model

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.3

* Added social quest builder event type

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.4

* Default completed at for scout social quest model

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.5

* Added daily claim streak builder event type

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.6

* add models

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.7

* Fixedc events

* ci: version bump to 0.94.1-rc-feat-sg-quest-p.8

---------

Co-authored-by: Automated Version Bump <[email protected]>
Co-authored-by: mattcasey <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent b6af8c9 commit 1888968
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@charmverse/core",
"version": "0.94.0",
"version": "0.94.1-rc-feat-sg-quest-p.8",
"description": "Core API for Charmverse",
"type": "commonjs",
"types": "./dist/cjs/index.d.ts",
Expand Down
101 changes: 101 additions & 0 deletions src/prisma/migrations/20241108001525_scout_social_quest/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Warnings:
- A unique constraint covering the columns `[dailyClaimEventId]` on the table `BuilderEvent` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[dailyClaimStreakEventId]` on the table `BuilderEvent` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[scoutSocialQuestId]` on the table `BuilderEvent` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.


ALTER TYPE "BuilderEventType" ADD VALUE 'daily_claim';
ALTER TYPE "BuilderEventType" ADD VALUE 'daily_claim_streak';
ALTER TYPE "BuilderEventType" ADD VALUE 'social_quest';

-- AlterTable
ALTER TABLE "BuilderEvent" ADD COLUMN "dailyClaimEventId" UUID,
ADD COLUMN "dailyClaimStreakEventId" UUID,
ADD COLUMN "scoutSocialQuestId" UUID;

-- AlterTable
ALTER TABLE "Scout" ALTER COLUMN "telegramId" SET DATA TYPE BIGINT;

-- CreateTable
CREATE TABLE "ScoutSocialQuest" (
"id" UUID NOT NULL,
"type" TEXT NOT NULL,
"userId" UUID NOT NULL,
"completedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "ScoutSocialQuest_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ScoutDailyClaimEvent" (
"id" UUID NOT NULL,
"userId" UUID NOT NULL,
"week" TEXT NOT NULL,
"dayOfWeek" INTEGER NOT NULL,

CONSTRAINT "ScoutDailyClaimEvent_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ScoutDailyClaimStreakEvent" (
"id" UUID NOT NULL,
"userId" UUID NOT NULL,
"week" TEXT NOT NULL,

CONSTRAINT "ScoutDailyClaimStreakEvent_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "ScoutSocialQuest_userId_idx" ON "ScoutSocialQuest"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "ScoutSocialQuest_type_userId_key" ON "ScoutSocialQuest"("type", "userId");

-- CreateIndex
CREATE INDEX "ScoutDailyClaimEvent_userId_week_idx" ON "ScoutDailyClaimEvent"("userId", "week");

-- CreateIndex
CREATE UNIQUE INDEX "ScoutDailyClaimEvent_userId_week_dayOfWeek_key" ON "ScoutDailyClaimEvent"("userId", "week", "dayOfWeek");

-- CreateIndex
CREATE INDEX "ScoutDailyClaimStreakEvent_userId_week_idx" ON "ScoutDailyClaimStreakEvent"("userId", "week");

-- CreateIndex
CREATE UNIQUE INDEX "ScoutDailyClaimStreakEvent_userId_week_key" ON "ScoutDailyClaimStreakEvent"("userId", "week");

-- CreateIndex
CREATE UNIQUE INDEX "BuilderEvent_dailyClaimEventId_key" ON "BuilderEvent"("dailyClaimEventId");

-- CreateIndex
CREATE UNIQUE INDEX "BuilderEvent_dailyClaimStreakEventId_key" ON "BuilderEvent"("dailyClaimStreakEventId");

-- CreateIndex
CREATE UNIQUE INDEX "BuilderEvent_scoutSocialQuestId_key" ON "BuilderEvent"("scoutSocialQuestId");

-- AddForeignKey
ALTER TABLE "BuilderEvent" ADD CONSTRAINT "BuilderEvent_dailyClaimEventId_fkey" FOREIGN KEY ("dailyClaimEventId") REFERENCES "ScoutDailyClaimEvent"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "BuilderEvent" ADD CONSTRAINT "BuilderEvent_dailyClaimStreakEventId_fkey" FOREIGN KEY ("dailyClaimStreakEventId") REFERENCES "ScoutDailyClaimStreakEvent"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "BuilderEvent" ADD CONSTRAINT "BuilderEvent_scoutSocialQuestId_fkey" FOREIGN KEY ("scoutSocialQuestId") REFERENCES "ScoutSocialQuest"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ScoutSocialQuest" ADD CONSTRAINT "ScoutSocialQuest_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Scout"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ScoutDailyClaimEvent" ADD CONSTRAINT "ScoutDailyClaimEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Scout"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ScoutDailyClaimStreakEvent" ADD CONSTRAINT "ScoutDailyClaimStreakEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Scout"("id") ON DELETE CASCADE ON UPDATE CASCADE;
143 changes: 95 additions & 48 deletions src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2788,37 +2788,40 @@ enum BuilderStatus {
}

model Scout {
createdAt DateTime @default(now())
id String @id @default(uuid()) @db.Uuid
email String?
path String @unique
displayName String
farcasterId Int? @unique
farcasterName String? // every user only has one farcaster account
telegramId Int? @unique
walletENS String?
avatar String?
bio String?
builderStatus BuilderStatus?
sendMarketing Boolean @default(false)
agreedToTermsAt DateTime?
onboardedAt DateTime?
currentBalance Int @default(0)
scoutWallet ScoutWallet[]
strikes BuilderStrike[]
events BuilderEvent[]
githubUser GithubUser[]
gemsPayoutEvents GemsPayoutEvent[]
pointsReceived PointsReceipt[] @relation("pointsReceiptRecipient")
pointsSent PointsReceipt[] @relation("pointsReceiptSender")
userWeeklyStats UserWeeklyStats[]
userSeasonStats UserSeasonStats[]
userAllTimeStats UserAllTimeStats[]
nftPurchaseEvents NFTPurchaseEvent[] @relation("nftPurchaseEventScout")
builderNfts BuilderNft[]
activities ScoutGameActivity[]
PendingNftTransaction PendingNftTransaction[]
builderCardActivities BuilderCardActivity[]
createdAt DateTime @default(now())
id String @id @default(uuid()) @db.Uuid
email String?
path String @unique
displayName String
farcasterId Int? @unique
farcasterName String? // every user only has one farcaster account
telegramId BigInt? @unique
walletENS String?
avatar String?
bio String?
builderStatus BuilderStatus?
sendMarketing Boolean @default(false)
agreedToTermsAt DateTime?
onboardedAt DateTime?
currentBalance Int @default(0)
scoutWallet ScoutWallet[]
strikes BuilderStrike[]
events BuilderEvent[]
githubUser GithubUser[]
gemsPayoutEvents GemsPayoutEvent[]
pointsReceived PointsReceipt[] @relation("pointsReceiptRecipient")
pointsSent PointsReceipt[] @relation("pointsReceiptSender")
userWeeklyStats UserWeeklyStats[]
userSeasonStats UserSeasonStats[]
userAllTimeStats UserAllTimeStats[]
nftPurchaseEvents NFTPurchaseEvent[] @relation("nftPurchaseEventScout")
builderNfts BuilderNft[]
activities ScoutGameActivity[]
PendingNftTransaction PendingNftTransaction[]
builderCardActivities BuilderCardActivity[]
scoutSocialQuests ScoutSocialQuest[]
dailyClaimEvents ScoutDailyClaimEvent[]
dailyClaimStreakEvents ScoutDailyClaimStreakEvent[]
@@index([path])
@@index([farcasterId])
Expand Down Expand Up @@ -2846,26 +2849,35 @@ enum BuilderEventType {
nft_purchase
proposal_passed
gems_payout
daily_claim
daily_claim_streak
social_quest
}

model BuilderEvent {
id String @id @default(uuid()) @db.Uuid
builderId String @db.Uuid
builder Scout @relation(fields: [builderId], references: [id], onDelete: Cascade)
type BuilderEventType
week String
season String
createdAt DateTime @default(now())
description String? // for misc_event type
bonusPartner String?
githubEventId String? @unique @db.Uuid
githubEvent GithubEvent? @relation(fields: [githubEventId], references: [id], onDelete: SetNull)
gemsPayoutEventId String? @unique @db.Uuid
gemsPayoutEvent GemsPayoutEvent? @relation(fields: [gemsPayoutEventId], references: [id], onDelete: SetNull)
nftPurchaseEventId String? @unique @db.Uuid
nftPurchaseEvent NFTPurchaseEvent? @relation(fields: [nftPurchaseEventId], references: [id], onDelete: SetNull)
pointsReceipts PointsReceipt[]
gemsReceipt GemsReceipt?
id String @id @default(uuid()) @db.Uuid
builderId String @db.Uuid
builder Scout @relation(fields: [builderId], references: [id], onDelete: Cascade)
type BuilderEventType
week String
season String
createdAt DateTime @default(now())
description String? // for misc_event type
bonusPartner String?
dailyClaimEventId String? @unique @db.Uuid
dailyClaimEvent ScoutDailyClaimEvent? @relation(fields: [dailyClaimEventId], references: [id], onDelete: SetNull)
dailyClaimStreakEventId String? @unique @db.Uuid
dailyClaimStreakEvent ScoutDailyClaimStreakEvent? @relation(fields: [dailyClaimStreakEventId], references: [id], onDelete: SetNull)
githubEventId String? @unique @db.Uuid
githubEvent GithubEvent? @relation(fields: [githubEventId], references: [id], onDelete: SetNull)
gemsPayoutEventId String? @unique @db.Uuid
gemsPayoutEvent GemsPayoutEvent? @relation(fields: [gemsPayoutEventId], references: [id], onDelete: SetNull)
nftPurchaseEventId String? @unique @db.Uuid
nftPurchaseEvent NFTPurchaseEvent? @relation(fields: [nftPurchaseEventId], references: [id], onDelete: SetNull)
pointsReceipts PointsReceipt[]
gemsReceipt GemsReceipt?
scoutSocialQuestId String? @unique @db.Uuid
scoutSocialQuest ScoutSocialQuest? @relation(fields: [scoutSocialQuestId], references: [id], onDelete: SetNull)
@@index([builderId])
@@index([githubEventId])
Expand Down Expand Up @@ -3180,3 +3192,38 @@ model ScoutWallet {
@@index([address])
@@index([scoutId])
}

model ScoutSocialQuest {
id String @id @default(uuid()) @db.Uuid
type String
userId String @db.Uuid
user Scout @relation(fields: [userId], references: [id], onDelete: Cascade)
completedAt DateTime @default(now())
event BuilderEvent?
@@unique([type, userId])
@@index([userId])
}

model ScoutDailyClaimEvent {
id String @id @default(uuid()) @db.Uuid
userId String @db.Uuid
user Scout @relation(fields: [userId], references: [id], onDelete: Cascade)
week String // '2024-W40'
dayOfWeek Int
event BuilderEvent?
@@unique([userId, week, dayOfWeek])
@@index([userId, week])
}

model ScoutDailyClaimStreakEvent {
id String @id @default(uuid()) @db.Uuid
userId String @db.Uuid
user Scout @relation(fields: [userId], references: [id], onDelete: Cascade)
week String // '2024-W40'
event BuilderEvent?
@@unique([userId, week])
@@index([userId, week])
}

0 comments on commit 1888968

Please sign in to comment.