Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

🔧 series floorprice #162

Merged
merged 3 commits into from
Mar 9, 2023
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
7 changes: 4 additions & 3 deletions src/mappings/utils/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ enum Query {
COUNT(distinct ne.current_owner) as unique_collectors,
COUNT(distinct ne.current_owner) as sold,
COUNT(ne.*) as total,
AVG(ne.price) as average_price,
MIN(NULLIF(ne.price, 0)) as floor_price,
COALESCE(MAX(e.meta :: bigint), 0) as highest_sale,
AVG(e.meta::bigint) as average_price,
MIN(NULLIF(e.meta::bigint, 0)) as floor_price,
COALESCE(MAX(e.meta::bigint), 0) as highest_sale,
COALESCE(SUM(e.meta::bigint), 0) as volume,
COUNT(e.*) as buys,
0 as emote_count
Expand All @@ -36,6 +36,7 @@ enum Query {
LEFT JOIN nft_entity ne on ce.id = ne.collection_id
JOIN event e on ne.id = e.nft_id
WHERE e.interaction = 'BUY'
OR e.interaction = 'LIST'
GROUP BY ce.id, me.image, ce.name
ORDER BY volume DESC
LIMIT 100`,
Expand Down
7 changes: 4 additions & 3 deletions src/server-extension/resolvers/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class SeriesResolver {
COUNT(distinct ne.current_owner) as unique_collectors,
COUNT(distinct ne.current_owner) as sold,
COUNT(ne.*) as total,
AVG(ne.price) as average_price,
MIN(NULLIF(ne.price, 0)) as floor_price,
AVG(e.meta::bigint) as average_price,
MIN(NULLIF(e.meta::bigint, 0)) as floor_price,
COALESCE(MAX(e.meta::bigint), 0) as highest_sale,
COALESCE(SUM(e.meta::bigint), 0) as volume,
COUNT(e.*) as buys
Expand All @@ -64,9 +64,10 @@ export class SeriesResolver {
LEFT JOIN nft_entity ne on ce.id = ne.collection_id
JOIN event e on ne.id = e.nft_id
WHERE e.interaction = 'BUY' ${computedDateRange}
OR e.interaction = 'LIST' ${computedDateRange}
GROUP BY ce.id, me.image, ce.name
ORDER BY ${orderBy} ${orderDirection}
LIMIT ${limit} OFFSET ${offset}`;
LIMIT ${limit} OFFSET ${offset}`
const result: SeriesEntity[] = await makeQuery(this.tx, NFTEntity, query);

return result;
Expand Down