Skip to content

Commit

Permalink
fix: add delete token traits resolver and increase traits job delay (#…
Browse files Browse the repository at this point in the history
…1313)

* fix: add delete token traits resolver and increasse job delay

* fix
  • Loading branch information
justraman authored Sep 25, 2024
1 parent 55eafe4 commit 1c73c77
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jobs/compute-traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { redisConfig } from './common'
export type JobData = { collectionId: string }

export const traitsQueue = new Queue<JobData>('traitsQueue', {
defaultJobOptions: { delay: 60_000, attempts: 2, removeOnComplete: true },
defaultJobOptions: { delay: 120_000, attempts: 2, removeOnComplete: true },
redis: redisConfig,
settings: {
maxStalledCount: 3,
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/claims/events/claimRequested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function claimRequested(ctx: CommonContext, block: BlockHeader, ite
createdAt: new Date(block.timestamp ?? 0),
})

await Promise.all([ctx.store.insert(claim)])
await Promise.all([ctx.store.save(claim)])

if (item.extrinsic) {
await Sns.getInstance().send({
Expand Down
35 changes: 35 additions & 0 deletions src/server-extension/resolvers/delete_token_traits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable max-classes-per-file */
import { Query, Resolver, Arg } from 'type-graphql'
import 'reflect-metadata'
import { EntityManager } from 'typeorm'

@Resolver()
export class DeleteTokenTraitsResolver {
constructor(private tx: () => Promise<EntityManager>) {}

@Query(() => Boolean)
async deleteTokenTraits(
@Arg('tokenId', {
description: 'token id e.g. 2100-17',
})
tokenId: string
): Promise<boolean> {
const manager = await this.tx()

await manager.query(
`
DELETE FROM trait_token WHERE token_id = $1
`,
[tokenId]
)

await manager.query(
`
DELETE FROM token_rarity WHERE token_id = $1
`,
[tokenId]
)

return true
}
}
2 changes: 2 additions & 0 deletions src/server-extension/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { RefreshCollectionsResolver } from './refresh_collections'
import { FuelTanksAccountsResolver } from './fueltanks-accounts'
import { ClaimableCollectionIdsResolver } from './claimable_colllection_ids'
import { SyncCollectionsResolver } from './sync_collections'
import { DeleteTokenTraitsResolver } from './delete_token_traits'

export {
TokenSalesHistoryResolver,
Expand All @@ -24,4 +25,5 @@ export {
MyTokensResolver,
ClaimsAccountNonceResolver,
SyncCollectionsResolver,
DeleteTokenTraitsResolver,
}

0 comments on commit 1c73c77

Please sign in to comment.