-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: material view erc721 holder statistic (#896)
* feat: material view erc721 holder statistic * refactor: index * refactor: review
- Loading branch information
1 parent
ec4280d
commit 8a24294
Showing
5 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
migrations/evm/20240905021812_m_view_erc721_holder_statistic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Knex } from 'knex'; | ||
import config from '../../config.json' assert { type: 'json' }; | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw(`set statement_timeout to ${config.erc721.statementTimeout}`); | ||
await knex.raw(` | ||
CREATE MATERIALIZED VIEW m_view_erc721_holder_statistic AS | ||
select count(*), erc721_token.owner, erc721_token.erc721_contract_address | ||
from erc721_token | ||
group by erc721_token.owner, erc721_token.erc721_contract_address; | ||
CREATE INDEX m_view_erc721_holder_statistic_owner_index | ||
ON m_view_erc721_holder_statistic (owner); | ||
CREATE INDEX m_view_erc721_holder_statistic_erc721_contract_address_count_index | ||
ON m_view_erc721_holder_statistic (erc721_contract_address, count); | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropMaterializedViewIfExists( | ||
'm_view_erc721_holder_statistic' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters