Add creator id to unique bettor ids
This commit is contained in:
parent
63d8e6739b
commit
d319b654ce
|
@ -64,10 +64,7 @@ const updateUniqueBettorsAndGiveCreatorBonus = async (
|
||||||
|
|
||||||
if (!previousUniqueBettorIds) {
|
if (!previousUniqueBettorIds) {
|
||||||
const contractBets = (
|
const contractBets = (
|
||||||
await firestore
|
await firestore.collection(`contracts/${contractId}/bets`).get()
|
||||||
.collection(`contracts/${contractId}/bets`)
|
|
||||||
.where('userId', '!=', contract.creatorId)
|
|
||||||
.get()
|
|
||||||
).docs.map((doc) => doc.data() as Bet)
|
).docs.map((doc) => doc.data() as Bet)
|
||||||
|
|
||||||
if (contractBets.length === 0) {
|
if (contractBets.length === 0) {
|
||||||
|
@ -82,9 +79,7 @@ const updateUniqueBettorsAndGiveCreatorBonus = async (
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isNewUniqueBettor =
|
const isNewUniqueBettor = !previousUniqueBettorIds.includes(bettorId)
|
||||||
!previousUniqueBettorIds.includes(bettorId) &&
|
|
||||||
bettorId !== contract.creatorId
|
|
||||||
|
|
||||||
const newUniqueBettorIds = uniq([...previousUniqueBettorIds, bettorId])
|
const newUniqueBettorIds = uniq([...previousUniqueBettorIds, bettorId])
|
||||||
// Update contract unique bettors
|
// Update contract unique bettors
|
||||||
|
@ -96,7 +91,9 @@ const updateUniqueBettorsAndGiveCreatorBonus = async (
|
||||||
uniqueBettorCount: newUniqueBettorIds.length,
|
uniqueBettorCount: newUniqueBettorIds.length,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (!isNewUniqueBettor) return
|
|
||||||
|
// No need to give a bonus for the creator's bet
|
||||||
|
if (!isNewUniqueBettor || bettorId == contract.creatorId) return
|
||||||
|
|
||||||
// Create combined txn for all new unique bettors
|
// Create combined txn for all new unique bettors
|
||||||
const bonusTxnDetails = {
|
const bonusTxnDetails = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user