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

feat: collection buy event resolver #37

Merged
merged 4 commits into from
Mar 21, 2022

Conversation

Jarsen136
Copy link
Contributor

@Jarsen136 Jarsen136 commented Mar 18, 2022

Add a resolver to return max and count of collection's events.

More details ref: kodadot/nft-gallery#2556

It's my first time contributing to the subsquid project. I encountered some problems connecting the local server, so I wrote the code directly and haven't tested it.

Please don't hesitate to point out my mistakes and give me some corrections. Thanks a lot! @vikiival

Copy link
Member

@vikiival vikiival left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks oki I would merge it into one query :)

Comment on lines 2 to 3
date(e.timestamp),
COALESCE(MAX(e.meta::bigint), 0) as max,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
date(e.timestamp),
COALESCE(MAX(e.meta::bigint), 0) as max,
date(e.timestamp),
COUNT(e.*) as count
COALESCE(MAX(e.meta::bigint), 0) as max,

Comment on lines 7 to 12

export const totalBuyEvent = `SELECT
COUNT(e.*) as count
FROM event e
LEFT JOIN nft_entity ne on ne.id = e.nft_id
WHERE e.interaction = 'BUY' AND ne.collection_id = $1;`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const totalBuyEvent = `SELECT
COUNT(e.*) as count
FROM event e
LEFT JOIN nft_entity ne on ne.id = e.nft_id
WHERE e.interaction = 'BUY' AND ne.collection_id = $1;`

@Jarsen136
Copy link
Contributor Author

@vikiival Thanks for your comments. I have change the code.

@Jarsen136
Copy link
Contributor Author

Thanks a lot for your help! ❤️

@Jarsen136 Jarsen136 requested a review from vikiival March 20, 2022 15:07
@vikiival vikiival merged commit f2c70e9 into kodadot:main Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants