Skip to content

Commit

Permalink
add refresh total ibc status
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTFM committed Aug 6, 2024
1 parent b79c6dc commit 34ef3d6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public void updateBlockchainStatsFromIbc() {
jdbcTemplate.execute("CALL public.update_flat_tables_ibc_txs(date_trunc('day', now())::timestamp without time zone);");
}

public void updateAlltimeIbcStats() {
jdbcTemplate.execute("REFRESH MATERIALIZED VIEW mv_ibc_transfer_stats;");
}

public void executeBlockchainCosmoshubStub() {
jdbcTemplate.execute("" +
"UPDATE\n" +
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/mapofzones/adaptor/processor/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ public void updateBlockchainStatsFromIbc() {
System.out.println("Finished updating blockchain stats from ibc!");
System.out.println("---------------");
}

@Transactional
public void updateAlltimeIbcStats() {
System.out.println("Starting running update alltime ibc stats");
customProcedureRepository.updateAlltimeIbcStats();
System.out.println("Finished updating alltime blockchain stats from ibc!");
System.out.println("---------------");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
case "update_blockchain_stats_from_ibc":
updateBlockchainStatsFromIbcScheduler(taskRegistrar);
break;
case "update_all_time_ibc_stats":
updateAlltimeIbcStatsScheduler(taskRegistrar);
break;
default:
System.out.println("No matching command-to-run value. Make sure to set it in the configurations.");
System.out.println("Available commands: update-flat-tables, update_blockchain_stats_from_ibc");
Expand All @@ -60,4 +63,14 @@ public void updateBlockchainStatsFromIbcScheduler(ScheduledTaskRegistrar taskReg
this.updateBlockchainStatsSyncTime
);
}

public void updateAlltimeIbcStatsScheduler(ScheduledTaskRegistrar taskRegistrar) {
processor.updateAlltimeIbcStats();
taskRegistrar.addFixedDelayTask(
() -> {
processor.updateAlltimeIbcStats();
},
Long.parseLong(updateFlatTablesSyncTime)
);
}
}
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ commands:
update_blockchain_stats_from_ibc:
# 00:10 UTC every day
sync-time: "10 0 0 * * ?"

update_all_time_ibc_stats:
# every one hour
sync-time: 3600000

spring:
main:
Expand Down

0 comments on commit 34ef3d6

Please sign in to comment.