Skip to content

Commit 1d4a7d0

Browse files
Merge pull request #161 from cardano-foundation/remove_tx_chart
chore: #125 drop tx_chart table and remove code related tx_chart
2 parents e5ff4c3 + 4e15417 commit 1d4a7d0

File tree

12 files changed

+12
-735
lines changed

12 files changed

+12
-735
lines changed

application/src/main/java/org/cardanofoundation/ledgersync/repository/TxChartRepository.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/repository/TxRepository.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22

33
import org.cardanofoundation.ledgersync.consumercommon.entity.Block;
44
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
5-
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx_;
6-
import org.cardanofoundation.ledgersync.projection.TxTimeProjection;
7-
import org.springframework.data.domain.Pageable;
8-
import org.springframework.data.jpa.repository.EntityGraph;
95
import org.springframework.data.jpa.repository.JpaRepository;
10-
import org.springframework.data.jpa.repository.Query;
11-
import org.springframework.data.repository.query.Param;
126
import org.springframework.stereotype.Repository;
137

148
import java.util.Collection;
@@ -18,33 +12,4 @@
1812
public interface TxRepository extends JpaRepository<Tx, Long> {
1913

2014
List<Tx> findAllByBlockIn(Collection<Block> blocks);
21-
22-
Tx findFirstByOrderByIdDesc();
23-
24-
@Query("SELECT tx.id as txId, "
25-
+ "tx.block.time as txTime, "
26-
+ "(SUM(CASE WHEN r IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithSc, "
27-
+ "(SUM(CASE WHEN r IS NULL AND tm IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithMetadataWithoutSc, "
28-
+ "(SUM(CASE WHEN r IS NULL AND tm IS NULL THEN 1 ELSE 0 END) != 0) AS simpleTx "
29-
+ "FROM Tx tx "
30-
+ "LEFT JOIN Redeemer r on r.tx = tx "
31-
+ "LEFT JOIN TxMetadata tm ON tm.tx = tx "
32-
+ "WHERE :id IS NULL OR tx.id > :id "
33-
+ "GROUP BY txId, txTime")
34-
List<TxTimeProjection> findTxWithTimeByIdGreaterThanOrNull(@Param("id") Long id);
35-
36-
@Query("SELECT tx.id as txId, "
37-
+ "tx.block.time as txTime, "
38-
+ "(SUM(CASE WHEN r IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithSc, "
39-
+ "(SUM(CASE WHEN r IS NULL AND tm IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithMetadataWithoutSc, "
40-
+ "(SUM(CASE WHEN r IS NULL AND tm IS NULL THEN 1 ELSE 0 END) != 0) AS simpleTx "
41-
+ "FROM Tx tx "
42-
+ "LEFT JOIN Redeemer r on r.tx = tx "
43-
+ "LEFT JOIN TxMetadata tm ON tm.tx = tx "
44-
+ "WHERE tx IN (:txs) "
45-
+ "GROUP BY txId, txTime")
46-
List<TxTimeProjection> findTxWithTimeByTxIn(@Param("txs") Collection<Tx> txs);
47-
48-
@EntityGraph(attributePaths = Tx_.BLOCK)
49-
List<Tx> findAllByOrderByBlockIdDescBlockIndexAsc(Pageable pageable);
5015
}

application/src/main/java/org/cardanofoundation/ledgersync/service/TxChartService.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/service/impl/TxChartServiceImpl.java

Lines changed: 0 additions & 185 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/service/impl/block/BlockSyncServiceImpl.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import org.cardanofoundation.ledgersync.aggregate.AggregatedSlotLeader;
1010
import org.cardanofoundation.ledgersync.consumercommon.entity.Block;
1111
import org.cardanofoundation.ledgersync.consumercommon.entity.SlotLeader;
12-
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
1312
import org.cardanofoundation.ledgersync.repository.BlockRepository;
14-
import org.cardanofoundation.ledgersync.repository.TxRepository;
1513
import org.cardanofoundation.ledgersync.service.*;
1614
import org.springframework.stereotype.Service;
1715
import org.springframework.transaction.annotation.Transactional;
@@ -28,14 +26,12 @@
2826
public class BlockSyncServiceImpl implements BlockSyncService {
2927

3028
BlockRepository blockRepository;
31-
TxRepository txRepository;
3229

3330
TransactionService transactionService;
3431
BlockDataService blockDataService;
3532
SlotLeaderService slotLeaderService;
3633
EpochService epochService;
3734
EpochParamService epochParamService;
38-
TxChartService txChartService;
3935
MetricCollectorService metricCollectorService;
4036
AggregatedDataCachingService aggregatedDataCachingService;
4137

@@ -72,7 +68,6 @@ public void handleBlockSync() {
7268
blockRepository.saveAll(blockMap.values());
7369
aggregatedDataCachingService.addBlockCount(allAggregatedBlocks.size());
7470
// Prepare and handle transaction contents
75-
Tx latestSavedTx = txRepository.findFirstByOrderByIdDesc();
7671
transactionService.prepareAndHandleTxs(blockMap, allAggregatedBlocks);
7772

7873
// Handle epoch data
@@ -84,9 +79,6 @@ public void handleBlockSync() {
8479
// Cache latest txs
8580
aggregatedDataCachingService.saveLatestTxs();
8681

87-
// Handle tx charts
88-
txChartService.handleTxChart(latestSavedTx);
89-
9082
// Finally, commit and clear the aggregated data
9183
blockDataService.clearBatchBlockData();
9284
aggregatedDataCachingService.commit();

application/src/main/java/org/cardanofoundation/ledgersync/service/impl/block/RollbackServiceImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class RollbackServiceImpl implements RollbackService {
5656
TxWitnessRepository txWitnessRepository;
5757
EpochService epochService;
5858
MultiAssetService multiAssetService;
59-
TxChartService txChartService;
6059
AggregatedDataCachingService aggregatedDataCachingService;
6160

6261

@@ -126,7 +125,6 @@ private void removeAllRollbackBlockData(List<Block> rollbackBlocks) {
126125
tx.getId(), tx.getHash(), tx.getBlockId()));
127126

128127
multiAssetService.rollbackMultiAssets(txsForRollback);
129-
txChartService.rollbackTxChart(txsForRollback);
130128
aggregatedDataCachingService.subtractTxCount(txsForRollback.size());
131129

132130
log.info("Deleting records from tables related to txs/blocks being rolled back");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS tx_chart;

0 commit comments

Comments
 (0)