-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create job to count token tx and add index for address tx count…
… table
- Loading branch information
1 parent
20a2945
commit c145441
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/org/cardanofoundation/job/repository/ledgersync/TokenTxCountRepository.java
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,16 @@ | ||
package org.cardanofoundation.job.repository.ledgersync; | ||
|
||
import jakarta.transaction.Transactional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import org.cardanofoundation.explorer.common.entity.ledgersync.TokenTxCount; | ||
|
||
public interface TokenTxCountRepository extends JpaRepository<TokenTxCount, Long> { | ||
@Modifying(clearAutomatically = true) | ||
@Transactional | ||
@Query(value = "REFRESH MATERIALIZED VIEW token_tx_count", nativeQuery = true) | ||
void refreshMaterializedView(); | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...in/resources/db/migration/ledgersync/V1_3_25__add_materialized_view_to_count_token_tx.sql
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,10 @@ | ||
DROP MATERIALIZED VIEW IF EXISTS token_tx_count; | ||
|
||
CREATE MATERIALIZED VIEW token_tx_count as | ||
SELECT ma.id as ident, count(distinct (ata.tx_hash)) as tx_count | ||
FROM address_tx_amount ata | ||
JOIN multi_asset ma ON ata.unit = ma.unit | ||
GROUP BY ma.id; | ||
|
||
CREATE INDEX token_tx_count_ident_idx ON token_tx_count(ident); | ||
CREATE INDEX token_tx_count_tx_count_idx ON token_tx_count(tx_count); |