-
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 address transaction
- Loading branch information
1 parent
4c4cf3b
commit 4fa6509
Showing
6 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/org/cardanofoundation/job/repository/ledgersync/AddressTxCountRepository.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.AddressTxCount; | ||
|
||
public interface AddressTxCountRepository extends JpaRepository<AddressTxCount, Long> { | ||
@Modifying(clearAutomatically = true) | ||
@Transactional | ||
@Query(value = "REFRESH MATERIALIZED VIEW address_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
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
8 changes: 8 additions & 0 deletions
8
...esources/db/migration/ledgersync/V1_3_24__add_materialized_view_for_address_tx_count_.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,8 @@ | ||
DROP MATERIALIZED VIEW IF EXISTS address_tx_count; | ||
|
||
CREATE MATERIALIZED VIEW address_tx_count AS | ||
SELECT add.address AS address, | ||
count(distinct ata.tx_hash) AS tx_count | ||
FROM address add | ||
left join address_tx_amount ata on ata.address = add.address | ||
GROUP BY add.address; |