diff --git a/src/clients/OtterspaceSubgraph.ts b/src/clients/OtterspaceSubgraph.ts index e8815612f..056db6407 100644 --- a/src/clients/OtterspaceSubgraph.ts +++ b/src/clients/OtterspaceSubgraph.ts @@ -38,9 +38,12 @@ query Badges($raft_id: String!, $address: Bytes!, $first: Int!, $skip: Int!) { }` const BADGE_SPEC_OWNERS_QUERY = ` -query Badges($badgeCid: String!) { +query Badges($badgeCid: String!, $skip: Int!, $first: Int!) { badges: badges( where: {spec: $badgeCid} + orderBy: id + first: $first + skip: $skip ){ id owner { diff --git a/src/services/BadgesService.ts b/src/services/BadgesService.ts index f092667b4..b58f927d4 100644 --- a/src/services/BadgesService.ts +++ b/src/services/BadgesService.ts @@ -117,26 +117,36 @@ export class BadgesService { landOwnerAddresses ) - const outcomes: AirdropOutcome[] = [] - const batches = splitArray([...eligibleUsers, ...usersWithBadgesToReinstate], 50) - - for (const batch of batches) { - const outcome = await BadgesService.giveBadgeToUsers(LAND_OWNER_BADGE_SPEC_CID, batch) - outcomes.push(outcome) + const airdropOutcomes: AirdropOutcome[] = [] + const airdropBatches = splitArray(eligibleUsers, 50) + for (const batch of airdropBatches) { + const outcome = await airdropWithRetry(LAND_OWNER_BADGE_SPEC_CID, batch) + airdropOutcomes.push(outcome) } - const failedOutcomes = outcomes.filter( + const reinstateResults = await BadgesService.reinstateBadge(LAND_OWNER_BADGE_SPEC_CID, usersWithBadgesToReinstate) + + const failedAirdropOutcomes = airdropOutcomes.filter( ({ status, error }) => status === AirdropJobStatus.FAILED && error !== ErrorReason.NoUserWithoutBadge && error !== ErrorReason.NoUserHasVoted ) - if (failedOutcomes.length > 0) { - console.error('Unable to give LandOwner badges', failedOutcomes) + if (failedAirdropOutcomes.length > 0) { + console.error('Unable to give LandOwner badges', failedAirdropOutcomes) ErrorService.report('Unable to give LandOwner badges', { category: ErrorCategory.Badges, - failedOutcomes, + failedAirdropOutcomes, + }) + } + + const failedReinstatements = reinstateResults.filter((result) => result.status === ActionStatus.Failed) + if (failedReinstatements.length > 0) { + console.error('Unable to reinstate LandOwner badges', failedReinstatements) + ErrorService.report('Unable to reinstate LandOwner badges', { + category: ErrorCategory.Badges, + failedReinstatements, }) }