This commit is contained in:
commit
be52431296
|
@ -32,6 +32,9 @@ async function main() {
|
||||||
user.achievements = await awardBettingStreakBadges(user)
|
user.achievements = await awardBettingStreakBadges(user)
|
||||||
console.log('Added achievements to user', user.id)
|
console.log('Added achievements to user', user.id)
|
||||||
// going to ignore backfilling the proven correct badges for now
|
// going to ignore backfilling the proven correct badges for now
|
||||||
|
} else {
|
||||||
|
// Make corrections to existing achievements
|
||||||
|
await awardMarketCreatorBadges(user)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -67,12 +70,11 @@ async function removeErrorBadges(user: User) {
|
||||||
|
|
||||||
async function awardMarketCreatorBadges(user: User) {
|
async function awardMarketCreatorBadges(user: User) {
|
||||||
// Award market maker badges
|
// Award market maker badges
|
||||||
const contracts = await getValues<Contract>(
|
const contracts = (
|
||||||
firestore
|
await getValues<Contract>(
|
||||||
.collection(`contracts`)
|
firestore.collection(`contracts`).where('creatorId', '==', user.id)
|
||||||
.where('creatorId', '==', user.id)
|
|
||||||
.where('resolution', '!=', 'CANCEL')
|
|
||||||
)
|
)
|
||||||
|
).filter((c) => !c.resolution || c.resolution != 'CANCEL')
|
||||||
|
|
||||||
const achievements = {
|
const achievements = {
|
||||||
...user.achievements,
|
...user.achievements,
|
||||||
|
@ -81,7 +83,12 @@ async function awardMarketCreatorBadges(user: User) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for (const threshold of marketCreatorBadgeRarityThresholds) {
|
for (const threshold of marketCreatorBadgeRarityThresholds) {
|
||||||
|
const alreadyHasBadge = user.achievements.marketCreator?.badges.some(
|
||||||
|
(b) => b.data.totalContractsCreated === threshold
|
||||||
|
)
|
||||||
|
if (alreadyHasBadge) continue
|
||||||
if (contracts.length >= threshold) {
|
if (contracts.length >= threshold) {
|
||||||
|
console.log(`User ${user.id} has at least ${threshold} contracts`)
|
||||||
const badge = {
|
const badge = {
|
||||||
type: 'MARKET_CREATOR',
|
type: 'MARKET_CREATOR',
|
||||||
name: 'Market Creator',
|
name: 'Market Creator',
|
||||||
|
|
|
@ -1220,7 +1220,7 @@ function getSourceUrl(notification: Notification) {
|
||||||
sourceType
|
sourceType
|
||||||
)}`
|
)}`
|
||||||
else if (sourceSlug)
|
else if (sourceSlug)
|
||||||
return `/${sourceSlug}#${getSourceIdForLinkComponent(
|
return `${sourceSlug}#${getSourceIdForLinkComponent(
|
||||||
sourceId ?? '',
|
sourceId ?? '',
|
||||||
sourceType
|
sourceType
|
||||||
)}`
|
)}`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user