Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add delete token traits resolver and increase traits job delay #1313

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
Loading