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

✨ Holder Entity for collection activity #33

Closed
wants to merge 10 commits into from

Conversation

daiagi
Copy link
Contributor

@daiagi daiagi commented Jul 8, 2023

No description provided.

@daiagi
Copy link
Contributor Author

daiagi commented Jul 8, 2023

@vikiival

@daiagi daiagi marked this pull request as draft July 8, 2023 15:28
@daiagi daiagi marked this pull request as ready for review July 10, 2023 05:17
@daiagi
Copy link
Contributor Author

daiagi commented Jul 10, 2023

cc @vikiival

@daiagi
Copy link
Contributor Author

daiagi commented Jul 10, 2023

allows for this query - which is what we need in collection activity:

query MyQuery {
  collectionEntities(limit: 3) {
    name
    holders(limit:3, orderBy: nftCount_DESC where: {nftCount_gt: 0}) {
      holder
      lastActivity
      nftCount
      totalBought
      totalSold
      nfts(limit: 2) {
        name
      }
    }
  }
}


result:

{
  "data": {
    "collectionEntities": [
      {
        "name": "5 year anniversary at Parity",
        "holders": [
          {
            "holder": "FsrKTLkQFD1fE5aRn65uPeuSUm54um3oj7J35Cbki3dVqM9",
            "lastActivity": "2021-10-20T18:58:00.242000Z",
            "nftCount": 1,
            "totalBought": "0",
            "totalSold": "0",
            "nfts": [
              {
                "name": "Marek Kotewicz, 5 years anniversary at Parity"
              }
            ]
          },
          {
            "holder": "FcxNWVy5RESDsErjwyZmPCW6Z8Y3fbfLzmou34YZTrbcraL",
            "lastActivity": "2021-10-28T16:28:12.253000Z",
            "nftCount": 1,
            "totalBought": "0",
            "totalSold": "0",
            "nfts": [
              {
                "name": "Gavin Wood, 5 years anniversary at Parity"
              }
            ]
          },
          {
            "holder": "E3J2HzvLxMpkJpSiQFwAq4y3dXM9KNYPb82YqmC1j1x2Fwk",
            "lastActivity": "2021-10-20T18:58:00.242000Z",
            "nftCount": 1,
            "totalBought": "0",
            "totalSold": "0",
            "nfts": [
              {
                "name": "Daniel Greeff, 5 years anniversary at Parity"
              }
            ]
          }
        ]
      },
      {
        "name": null,
        "holders": []
      },
      {
        "name": "Gav's NFTs",
        "holders": [
          {
            "holder": "DBHNS3re4bsjUVNtrLqp12ZctCeTA4GnKZWgPLvVVzCC9Zc",
            "lastActivity": "2021-09-29T10:53:42.256000Z",
            "nftCount": 1,
            "totalBought": "0",
            "totalSold": "0",
            "nfts": []
          },
          {
            "holder": "GbqtkjvQKWsgovW69Ga4WBnJxH3fSv3XkP7yLWC33j4yaQB",
            "lastActivity": "2021-10-02T09:46:06.483000Z",
            "nftCount": 1,
            "totalBought": "0",
            "totalSold": "0",
            "nfts": [
              {
                "name": "Mamacita"
              }
            ]
          }
        ]
      }
    ]
  }
}


async handleMint({ ownerId, collection, timestamp }: HandleMintParams): Promise<HA> {
const holderActivity = await this.getOrCreateHolder(ownerId, collection, timestamp)
await this.store.update(HA, { id: holderActivity.id }, { nftCount: 1, lastActivity: timestamp })
Copy link
Member

Choose a reason for hiding this comment

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

@vikiival
Copy link
Member

Hello sir,

I made a resolver for that, calculation time is about ~46 on the prod DB

kodadot/loligo#32 (comment)

@daiagi
Copy link
Contributor Author

daiagi commented Jul 10, 2023

Ok
Does the resolver also return the individual nfts that a holder has?

@vikiival
Copy link
Member

Does the resolver also return the individual nfts that a holder has?

No but I won't overfetch the resolver.
Rather do lazy loading in separated query

@daiagi
Copy link
Contributor Author

daiagi commented Jul 11, 2023

so... I understand you prefer resolver approach over new entities?

@vikiival
Copy link
Member

I understand you prefer resolver approach over new entities?

I prefer simple (working) things first. This is honestly a bit over-engineered and there other things to be solved on the entity level like ...

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