Skip to content

Commit

Permalink
add volume trade in top collection
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed Nov 28, 2023
1 parent 037c2d9 commit f3cda1b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/server-extension/resolvers/top_collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class CollectionRow {
@Field({ nullable: true })
volume_change!: string

@Field({ nullable: true })
volume_traded!: string

@Field({ nullable: false })
volume!: string

Expand Down Expand Up @@ -95,14 +98,17 @@ export class TopCollectionResolver {
const builder = manager
.createQueryBuilder()
.addSelect('collectionId AS id')
.addSelect('( SELECT COUNT(*)::int FROM collection_account a where a.collection_id = l.collectionId ) AS users')
.addSelect('(SELECT COUNT(*)::int FROM collection_account a where a.collection_id = l.collectionId ) AS users')
.addSelect('metadata AS metadata')
.addSelect('stats AS stats')
.addSelect('volume_last_duration AS volume')
.addSelect('sales_last_duration AS sales')
.addSelect(
'CASE WHEN volume_previous_duration != 0 THEN ROUND((volume_last_duration - volume_previous_duration) * 100 / volume_previous_duration, 2) ELSE null END AS volume_change'
)
.addSelect(
'CASE WHEN volume_previous_duration != 0 THEN ROUND((volume_last_duration - volume_previous_duration), 2) ELSE volume_last_duration END AS volume_traded'
)
.from((qb) => {
const inBuilder = qb
.select('collection.id AS collectionId')
Expand Down

0 comments on commit f3cda1b

Please sign in to comment.