Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
chore: attempt to fix num holders
Browse files Browse the repository at this point in the history
  • Loading branch information
nemo83 committed Jul 15, 2024
1 parent ae130fe commit 6de07f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.cardanofoundation.job.projection;

public interface TokenNumberHoldersProjection {
String getUnit();

Long getNumberOfHolders();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import org.cardanofoundation.explorer.common.entity.compositeKey.AddressTxAmountId;
import org.cardanofoundation.explorer.common.entity.ledgersync.AddressTxAmount;
import org.cardanofoundation.job.model.TokenNumberHolders;
import org.cardanofoundation.job.model.TokenVolume;
import org.cardanofoundation.job.projection.StakeTxProjection;
import org.cardanofoundation.job.projection.TokenNumberHoldersProjection;
import org.cardanofoundation.job.projection.UniqueAccountTxCountProjection;

public interface AddressTxAmountRepository
Expand Down Expand Up @@ -147,12 +147,13 @@ List<TokenVolume> sumBalanceAfterBlockSlot(
@Query(
value =
"""
SELECT new org.cardanofoundation.job.model.TokenNumberHolders(unit, count(address))
SELECT unit, count(address) AS number_of_holders
FROM address_balance_view
WHERE unit IN :units
AND quantity > 0
GROUP BY unit
""",
nativeQuery = true)
List<TokenNumberHolders> countHoldersByMultiAssetIdInRange(@Param("units") List<String> units);
List<TokenNumberHoldersProjection> countHoldersByMultiAssetIdInRange(
@Param("units") List<String> units);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import org.springframework.stereotype.Service;

import org.cardanofoundation.job.model.TokenNumberHolders;
import org.cardanofoundation.job.projection.TokenNumberHoldersProjection;
import org.cardanofoundation.job.repository.ledgersync.AddressTxAmountRepository;
import org.cardanofoundation.job.service.MultiAssetService;
import org.cardanofoundation.job.util.StreamUtil;
Expand All @@ -35,6 +35,8 @@ public class MultiAssetServiceImpl implements MultiAssetService {
public Map<String, Long> getMapNumberHolderByUnits(List<String> units) {
var numberOfHolders = addressTxAmountRepository.countHoldersByMultiAssetIdInRange(units);
return StreamUtil.toMap(
numberOfHolders, TokenNumberHolders::getUnit, TokenNumberHolders::getNumberOfHolders);
numberOfHolders,
TokenNumberHoldersProjection::getUnit,
TokenNumberHoldersProjection::getNumberOfHolders);
}
}

0 comments on commit 6de07f1

Please sign in to comment.