Skip to content

Commit

Permalink
Merge pull request #161 from cardano-foundation/remove_tx_chart
Browse files Browse the repository at this point in the history
chore: #125 drop tx_chart table and remove code related tx_chart
  • Loading branch information
Sotatek-HuyLe3a authored Apr 11, 2024
2 parents e5ff4c3 + 4e15417 commit 1d4a7d0
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 735 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import org.cardanofoundation.ledgersync.consumercommon.entity.Block;
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx_;
import org.cardanofoundation.ledgersync.projection.TxTimeProjection;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

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

List<Tx> findAllByBlockIn(Collection<Block> blocks);

Tx findFirstByOrderByIdDesc();

@Query("SELECT tx.id as txId, "
+ "tx.block.time as txTime, "
+ "(SUM(CASE WHEN r IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithSc, "
+ "(SUM(CASE WHEN r IS NULL AND tm IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithMetadataWithoutSc, "
+ "(SUM(CASE WHEN r IS NULL AND tm IS NULL THEN 1 ELSE 0 END) != 0) AS simpleTx "
+ "FROM Tx tx "
+ "LEFT JOIN Redeemer r on r.tx = tx "
+ "LEFT JOIN TxMetadata tm ON tm.tx = tx "
+ "WHERE :id IS NULL OR tx.id > :id "
+ "GROUP BY txId, txTime")
List<TxTimeProjection> findTxWithTimeByIdGreaterThanOrNull(@Param("id") Long id);

@Query("SELECT tx.id as txId, "
+ "tx.block.time as txTime, "
+ "(SUM(CASE WHEN r IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithSc, "
+ "(SUM(CASE WHEN r IS NULL AND tm IS NOT NULL THEN 1 ELSE 0 END) != 0) AS txWithMetadataWithoutSc, "
+ "(SUM(CASE WHEN r IS NULL AND tm IS NULL THEN 1 ELSE 0 END) != 0) AS simpleTx "
+ "FROM Tx tx "
+ "LEFT JOIN Redeemer r on r.tx = tx "
+ "LEFT JOIN TxMetadata tm ON tm.tx = tx "
+ "WHERE tx IN (:txs) "
+ "GROUP BY txId, txTime")
List<TxTimeProjection> findTxWithTimeByTxIn(@Param("txs") Collection<Tx> txs);

@EntityGraph(attributePaths = Tx_.BLOCK)
List<Tx> findAllByOrderByBlockIdDescBlockIndexAsc(Pageable pageable);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.cardanofoundation.ledgersync.aggregate.AggregatedSlotLeader;
import org.cardanofoundation.ledgersync.consumercommon.entity.Block;
import org.cardanofoundation.ledgersync.consumercommon.entity.SlotLeader;
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
import org.cardanofoundation.ledgersync.repository.BlockRepository;
import org.cardanofoundation.ledgersync.repository.TxRepository;
import org.cardanofoundation.ledgersync.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -28,14 +26,12 @@
public class BlockSyncServiceImpl implements BlockSyncService {

BlockRepository blockRepository;
TxRepository txRepository;

TransactionService transactionService;
BlockDataService blockDataService;
SlotLeaderService slotLeaderService;
EpochService epochService;
EpochParamService epochParamService;
TxChartService txChartService;
MetricCollectorService metricCollectorService;
AggregatedDataCachingService aggregatedDataCachingService;

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

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

// Handle tx charts
txChartService.handleTxChart(latestSavedTx);

// Finally, commit and clear the aggregated data
blockDataService.clearBatchBlockData();
aggregatedDataCachingService.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class RollbackServiceImpl implements RollbackService {
TxWitnessRepository txWitnessRepository;
EpochService epochService;
MultiAssetService multiAssetService;
TxChartService txChartService;
AggregatedDataCachingService aggregatedDataCachingService;


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

multiAssetService.rollbackMultiAssets(txsForRollback);
txChartService.rollbackTxChart(txsForRollback);
aggregatedDataCachingService.subtractTxCount(txsForRollback.size());

log.info("Deleting records from tables related to txs/blocks being rolled back");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS tx_chart;
Loading

0 comments on commit 1d4a7d0

Please sign in to comment.