-
Notifications
You must be signed in to change notification settings - Fork 2
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
Calculate rarity score per ERC-721 items #12
Comments
First we need to change attribute schema from JSON to actual entity. However it is hackable to do so via CREATE OR REPLACE view trait_list as
select
x.acc ->> 'trait' trait,
x.acc ->> 'value' "value",
m.id
from metadata_entity m
cross join lateral jsonb_array_elements(m.attributes) as x(acc); to get counts for attributes simply run SELECT
trait,
value,
count(value)
FROM
trait_list
GROUP BY
GROUPING SETS (
(trait),
(trait, value)
); this will tell you the counts for each trait-value and also total for each trait to sum it up: select
trait,
value,
count(value),
ROUND((count(value) / sum(count(value)) over (partition by trait)) * 100, 2) as rarity
from trait_list
group by trait, value
order by value; this will return:
then we need to basically for each NFT calculate the avg rarity |
This is imo most effective way to calculate it, may @dzlzv can have an opinion since he has PhD from math ;D |
for ERC-721 add
after create was called:
ref
articles:
The text was updated successfully, but these errors were encountered: