Skip to content

Commit

Permalink
add catch for queue
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed Apr 17, 2023
1 parent 5bd67c5 commit 9706d86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ type CollectionStats {
floorPrice: BigInt
lastSale: BigInt
highestSale: BigInt
supply: BigInt!
supply: BigInt
tokenCount: Int!
salesCount: Int!
rank: Int!
Expand Down
9 changes: 4 additions & 5 deletions src/jobs/compute-traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const traitsQueue = new Queue<JobData>('traitsQueue', {
redis: {
port: 6379,
host: config.redisHost,
retryStrategy: (times) => {
return Math.min(times * 200, 2000)
// 200ms to 4secs
},
},
})

Expand All @@ -38,7 +34,10 @@ const computeTraits = async (collectionId: string) => {
return
} */

traitsQueue.add({ collectionId }, { jobId: collectionId })
traitsQueue.add({ collectionId }, { jobId: collectionId }).catch(() => {
console.log('Closing connection as Redis is not available')
traitsQueue.close(true)
})
}

// eslint-disable-next-line sonarjs/cognitive-complexity
Expand Down
11 changes: 5 additions & 6 deletions src/model/generated/_collectionStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class CollectionStats {
private _floorPrice!: bigint | undefined | null
private _lastSale!: bigint | undefined | null
private _highestSale!: bigint | undefined | null
private _supply!: bigint
private _supply!: bigint | undefined | null
private _tokenCount!: number
private _salesCount!: number
private _rank!: number
Expand All @@ -18,7 +18,7 @@ export class CollectionStats {
this._floorPrice = json.floorPrice == null ? undefined : marshal.bigint.fromJSON(json.floorPrice)
this._lastSale = json.lastSale == null ? undefined : marshal.bigint.fromJSON(json.lastSale)
this._highestSale = json.highestSale == null ? undefined : marshal.bigint.fromJSON(json.highestSale)
this._supply = marshal.bigint.fromJSON(json.supply)
this._supply = json.supply == null ? undefined : marshal.bigint.fromJSON(json.supply)
this._tokenCount = marshal.int.fromJSON(json.tokenCount)
this._salesCount = marshal.int.fromJSON(json.salesCount)
this._rank = marshal.int.fromJSON(json.rank)
Expand Down Expand Up @@ -51,12 +51,11 @@ export class CollectionStats {
this._highestSale = value
}

get supply(): bigint {
assert(this._supply != null, 'uninitialized access')
get supply(): bigint | undefined | null {
return this._supply
}

set supply(value: bigint) {
set supply(value: bigint | undefined | null) {
this._supply = value
}

Expand Down Expand Up @@ -110,7 +109,7 @@ export class CollectionStats {
floorPrice: this.floorPrice == null ? undefined : marshal.bigint.toJSON(this.floorPrice),
lastSale: this.lastSale == null ? undefined : marshal.bigint.toJSON(this.lastSale),
highestSale: this.highestSale == null ? undefined : marshal.bigint.toJSON(this.highestSale),
supply: marshal.bigint.toJSON(this.supply),
supply: this.supply == null ? undefined : marshal.bigint.toJSON(this.supply),
tokenCount: this.tokenCount,
salesCount: this.salesCount,
rank: this.rank,
Expand Down

0 comments on commit 9706d86

Please sign in to comment.