-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
@vikiival lmk if this is ok, then I can also charge for kodadot/loligo#10 |
Hello please check the PR that was opened by @Matehoo |
Ohh didn't notice there should also be |
No worries, everything should be explained there. If something is not clear happy to explain |
Feel free to do a review, if it's same as yours let's merge it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tiny cosmetic stuff, LGTM
static createQueryBuilder(arg0: string) { | ||
throw new Error('Method not implemented.') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this generated by squid @alko89 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work for me on Rococo
Here is log output:
✔ success [BURN] 3647975502-8 by bXjMVEdCzhjYbPc5rJk7NvPSDRiiNuCT3GdqohFp3wdpzJL6Z
FATAL sqd:processor QueryFailedError: syntax error at or near "undefined"
at PostgresQueryRunner.query (.../snek/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async DataSource.query (.../snek/node_modules/typeorm/data-source/DataSource.js:341:20)
at async calculateCollectionOwnerCountAndDistribution (.../snek/lib/mappings/utils/entity.js:63:22)
at async handleTokenBurn (.../snek/lib/mappings/index.js:188:42)
at async HandlerRunner.processBlock (.../snek/node_modules/@subsquid/substrate-processor/lib/processor/handlerProcessor.js:505:25)
at async .../snek/node_modules/@subsquid/typeorm-store/lib/database.js:157:13
at async EntityManager.transaction (.../snek/node_modules/typeorm/entity-manager/EntityManager.js:72:28)
at async FullTypeormDatabase.runTransaction (.../snek/node_modules/@subsquid/typeorm-store/lib/database.js:155:9)
at async FullTypeormDatabase.transact (.../snek/node_modules/@subsquid/typeorm-store/lib/database.js:64:24)
query:
SELECT COUNT(DISTINCT current_owner) AS distribution,
COUNT(current_owner) AS owner_count
undefined
FROM nft_entity
WHERE collection_id = '3647975502-8'
undefined
driverError: {"length":99,"name":"error","severity":"ERROR","code":"42601","position":"103","file":"scan.l","line":"1176","routine":"scanner_yyerror","stack":"error: syntax error at or near \"undefined\"\n at Parser.parseErrorMessage (.../snek/node_modules/pg-protocol/dist/parser.js:287:98)\n at Parser.handlePacket (.../snek/node_modules/pg-protocol/dist/parser.js:126:29)\n at Parser.parse (.../snek/node_modules/pg-protocol/dist/parser.js:39:38)\n at Socket.<anonymous> (.../snek/node_modules/pg-protocol/dist/index.js:11:42)\n at Socket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:315:12)\n at readableAddChunk (node:internal/streams/readable:289:9)\n at Socket.Readable.push (node:internal/streams/readable:228:10)\n at TCP.onStreamRead (node:internal/stream_base_commons:190:23)"}
length: 99
severity: ERROR
code: 42601
position: 103
file: scan.l
line: 1176
routine: scanner_yyerror
blockHeight: 750082
blockHash: 0x429b514c452a93b57db272bcc16ebe353c1edbf23a0181a6abcac9aed4f89de2
make: *** [process] Error 1
@alko89 please make sure that it runs |
src/mappings/utils/entity.ts
Outdated
const query = ` | ||
SELECT COUNT(DISTINCT current_owner) AS distribution, | ||
COUNT(current_owner) AS owner_count | ||
${ | ||
newOwner | ||
&& ` | ||
,(SELECT max(CASE | ||
WHEN current_owner = '${newOwner}' THEN 0 | ||
ELSE 1 | ||
END) | ||
FROM nft_entity) AS adjustment | ||
` | ||
} | ||
FROM nft_entity | ||
WHERE collection_id = '${collectionId}' | ||
${newOwner && `AND current_owner != '${originalOwner}'`} | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is difficult to read, I suggest this workaround (but not so pretty)
const query = ` | |
SELECT COUNT(DISTINCT current_owner) AS distribution, | |
COUNT(current_owner) AS owner_count | |
${ | |
newOwner | |
&& ` | |
,(SELECT max(CASE | |
WHEN current_owner = '${newOwner}' THEN 0 | |
ELSE 1 | |
END) | |
FROM nft_entity) AS adjustment | |
` | |
} | |
FROM nft_entity | |
WHERE collection_id = '${collectionId}' | |
${newOwner && `AND current_owner != '${originalOwner}'`} | |
`; | |
let query; | |
if (newOwner && originalOwner) { | |
query = `SELECT | |
COUNT(DISTINCT current_owner) AS distribution, | |
COUNT(current_owner) AS owner_count, | |
( | |
SELECT max( | |
CASE | |
WHEN current_owner = '${newOwner}' THEN 0 | |
ELSE 1 | |
END | |
) | |
FROM nft_entity | |
) AS adjustment | |
FROM nft_entity | |
WHERE collection_id = '${collectionId}' | |
AND current_owner != '${originalOwner}'`; | |
} | |
query = `SELECT | |
COUNT(DISTINCT current_owner) AS distribution, | |
COUNT(current_owner) AS owner_count | |
FROM nft_entity | |
WHERE collection_id = '${collectionId}'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after this change build still not ok
FATAL sqd:processor AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
(0, assert_1.default)(this.isV81)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pfff leeeet me fix that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new event version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roiLeo did you maybe forgot to rebuild? I've just run make process
after building and didn't encounter the error. I applied your suggestion.
% make process
...
⬤ debug metadata: ipfs://ipfs/bafkreigzmr4zy7orconzhi2a6xofr7p6bvx2budsiowgi5kxu3qhcykns4
✔ success [MINT] 2653871371-4
☐ pending [LIST]: 1923312
⬤ debug list: {
"caller": "bXivCveEn3hMf4Cwt4q8uD7JQ2e58J9Mg1dbrgWvTNZZegR1p",
"blockNumber": "1923312",
"timestamp": "2023-04-12T02:44:48.181Z",
"collectionId": "2653871371",
"sn": "4",
"price": "1000000"
}
✔ success [LIST] 2653871371-4 by bXivCveEn3hMf4Cwt4q8uD7JQ2e58J9Mg1dbrgWvTNZZegR1p} for 1000000
☐ pending [ASSET REGISTER]: 1931806
✔ success [ASSET REGISTER]: by 1000021 is Calamari
☐ pending [BURN]: 1953949
⬤ debug burn: {
"caller": "bXmPf7DcVmFuHEmzH3UX8t6AUkfNQW8pnTeXGhFhqbfngjAak",
"blockNumber": "1953949",
"timestamp": "2023-04-20T15:05:36.153Z",
"collectionId": "1",
"sn": "95"
}
✔ success [BURN] 1-95 by bXmPf7DcVmFuHEmzH3UX8t6AUkfNQW8pnTeXGhFhqbfngjAak
ℹ info [CACHE UPDATE] PASSED TIME - 24296.799783333332 MINS
ℹ info [METADATA CACHE UPDATE] PASSED TIME - 24296.799783333332 MINS
ℹ info [MISSING METADATA] - NONE
✔ success [METADATA CACHE UPDATE]
✔ success [CACHE UPDATE]
19:11:42 INFO sqd:processor 1954261 / 1954262, rate: 75731 blocks/sec, mapping: 26 blocks/sec, 73 items/sec, ingest: 470 blocks/sec, eta: 0s
19:11:42 INFO sqd:processor 1954262 / 1954262, rate: 75727 blocks/sec, mapping: 26 blocks/sec, 73 items/sec, ingest: 445 blocks/sec, eta: 0s
19:11:43 INFO sqd:processor 1954263 / 1954263, rate: 73026 blocks/sec, mapping: 26 blocks/sec, 73 items/sec, ingest: 424 blocks/sec, eta: 0s
19:12:08 INFO sqd:processor 1954264 / 1954264, rate: 37387 blocks/sec, mapping: 26 blocks/sec, 73 items/sec, ingest: 405 blocks/sec, eta: 0s
19:12:33 INFO sqd:processor 1954265 / 1954265, rate: 25127 blocks/sec, mapping: 26 blocks/sec, 73 items/sec, ingest: 406 blocks/sec, eta: 0s
Co-authored-by: roiLeo <medina.leo42@gmail.com>
…feat/142-collection-stats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ process wfm
sqd:processor 1956220 / 1956220, rate: 5786 blocks/sec, mapping: 5 blocks/sec, 13 items/sec, ingest: 22 blocks/sec, eta: 0s
but:
query MyQuery {
collectionEntities(limit: 5, orderBy: distribution_DESC) {
ownerCount
supply
volume
highestSale
floor
distribution
}
}
{
"data": {
"collectionEntities": [
{
"ownerCount": 0,
"supply": 0,
"volume": "0",
"highestSale": "0",
"floor": "0",
"distribution": 0
},
{
"ownerCount": 0,
"supply": 0,
"volume": "0",
"highestSale": "0",
"floor": "0",
"distribution": 0
},
{
"ownerCount": 0,
"supply": 0,
"volume": "0",
"highestSale": "0",
"floor": "0",
"distribution": 0
},
{
"ownerCount": 0,
"supply": 0,
"volume": "0",
"highestSale": "0",
"floor": "0",
"distribution": 0
},
{
"ownerCount": 0,
"supply": 0,
"volume": "0",
"highestSale": "0",
"floor": "0",
"distribution": 0
}
]
}
}
same for ownerCount_DESC
, works with volume.
Could you take a look?
@roiLeo fixed, used event id instead of collection id in the query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
✅ wfm
Thank you for your contribution to the KodaDot Indexer.
👇 _ Let's make a quick check before the contribution.
PR type
What's new?
Before submitting Pull Request, please make sure:
Optional
Screenshot