-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send message to welcome users (#4765)
* Send message to welcome users * Fix CI * Add dependency on internal package * Add the script for the waitlist tier invites * Cleanup * Fix types * Cleanup messages and types * Update scripts
- Loading branch information
Showing
23 changed files
with
264 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { log } from "@charmverse/core/log"; | ||
import { Prisma, prisma } from "@charmverse/core/prisma-client"; | ||
import { ConnectWaitlistTier, getWaitlistRange } from "@packages/scoutgame/waitlist/scoring/constants"; | ||
import { welcomeFromWaitlistToScoutgame } from '@packages/scoutgame/waitlist/welcomeToScoutgame'; | ||
|
||
|
||
async function welcomeWaitlistTier(tier: ConnectWaitlistTier) { | ||
|
||
const tierInfo = getWaitlistRange(tier); | ||
|
||
const whereQuery: Prisma.ConnectWaitlistSlotWhereInput = tier === 'legendary' ? { | ||
percentile: { | ||
gte: tierInfo.min, | ||
} | ||
} : tier === 'common' ? { | ||
percentile: { | ||
lte: tierInfo.max | ||
} | ||
|
||
} | ||
// Other tiers have a minMax range | ||
: { | ||
percentile: { | ||
gte: tierInfo.min, | ||
lte: tierInfo.max | ||
} | ||
}; | ||
|
||
const existingScouts = await prisma.scout.findMany({ | ||
where: { | ||
farcasterId: { | ||
gte: 1 | ||
} | ||
}, | ||
select: { | ||
farcasterId: true | ||
} | ||
}) | ||
|
||
// Only message users who are not already scouts | ||
const users = await prisma.connectWaitlistSlot.findMany({ | ||
where: {...whereQuery, fid: {notIn: existingScouts.map(scout => scout.farcasterId).filter(Boolean) as number[]}, isPartnerAccount: {not: true}}, | ||
orderBy: { | ||
fid: 'asc' | ||
}, | ||
skip: 2 | ||
}); | ||
|
||
const totalUsersInTier = users.length; | ||
|
||
log.info(`Processing ${totalUsersInTier} users in tier ${tier}`); | ||
|
||
|
||
const limit = totalUsersInTier; | ||
// const limit = 1; | ||
|
||
for (let i = 0; i < limit; i++) { | ||
const user = users[i]; | ||
console.log(`Processing FID:${user.fid} ${user.username} user ${i + 1} of ${totalUsersInTier}`); | ||
await welcomeFromWaitlistToScoutgame({fid: user.fid}); | ||
} | ||
|
||
} | ||
|
||
|
||
// welcomeWaitlistTier('rare').then(console.log).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const NEYNAR_API_BASE_URL = 'https://api.neynar.com/v2/farcaster'; | ||
|
||
export const NEYNAR_API_KEY = process.env.NEYNAR_API_KEY as string; | ||
|
||
export const NEYNAR_SIGNER_ID = process.env.NEYNAR_SIGNER_ID as string; | ||
export const NEYNAR_SIGNER_PUBLIC_KEY = process.env.NEYNAR_SIGNER_PUBLIC_KEY as string; |
2 changes: 1 addition & 1 deletion
2
lib/farcaster/lookupUserByCustodyAddress.ts → ...rcaster/src/lookupUserByCustodyAddress.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 15 additions & 8 deletions
23
lib/farcaster/messaging/writeToFarcaster.ts → ...rcaster/src/messaging/writeToFarcaster.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/scoutgame/src/waitlist/scoring/__tests__/getWaitlistRange.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getWaitlistRange, waitlistTiers } from '../constants'; | ||
|
||
describe('getWaitlistRange', () => { | ||
it('should return the correct range for each tier', () => { | ||
const expectedRanges = { | ||
common: { min: 1, max: 30 }, | ||
rare: { min: 31, max: 60 }, | ||
epic: { min: 61, max: 80 }, | ||
mythic: { min: 81, max: 95 }, | ||
legendary: { min: 96, max: 100 } | ||
}; | ||
|
||
waitlistTiers.forEach((tier) => { | ||
const { min, max } = getWaitlistRange(tier); | ||
expect({ min, max }).toEqual(expectedRanges[tier]); | ||
}); | ||
}); | ||
|
||
it('should throw an error for an invalid tier', () => { | ||
expect(() => getWaitlistRange('invalid-tier' as any)).toThrow('Invalid tier: invalid-tier'); | ||
}); | ||
}); |
Oops, something went wrong.