CodeChain-io / CodeChain-io/codechain-indexer

Make the AggsUTXOs table migration script insert rows that have 0 quantity value

Open
#357 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Here is the AggsUTXOs table's migration script.

```
INSERT INTO "AggsUTXOs"("assetType", "address", "totalAssetQuantity", "utxoQuantity", "createdAt", "updatedAt")
SELECT "assetType", "address", SUM("quantity") as "totalAssetQuantity", COUNT(*) as "utxoQuantity", NOW(), NOW()
FROM "UTXOs" WHERE "usedBlockNumber" IS NULL GROUP BY "assetType", "address"
```

To ignore used UTXOs, the migration script filters the used UTXOs using the where clause. If a user sent all assets they have to another user, the quantity column value of the AggsUTXOs table's row will be zero. The migration script above does not insert the row that has the zero value in the quantity column.

This behavior is subtle. And can be ignored.

Contributor guide

No contributing guide indexed for this repository

Research direction

The migration file containing the shown AggsUTXOs INSERT is the starting point; inspect how the WHERE clause and aggregation handle zero-quantity data. Update the migration so the relevant zero-quantity AggsUTXOs row is inserted, then verify it with data matching the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.