-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update address controller when migrate with new ls schema
- Loading branch information
1 parent
78af01b
commit 5ee08e0
Showing
14 changed files
with
874 additions
and
612 deletions.
There are no files selected for viewing
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
5 changes: 3 additions & 2 deletions
5
src/main/java/org/cardanofoundation/explorer/api/mapper/AddressMapper.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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
package org.cardanofoundation.explorer.api.mapper; | ||
|
||
import org.cardanofoundation.explorer.api.model.response.address.AddressResponse; | ||
import org.mapstruct.Mapper; | ||
|
||
import org.cardanofoundation.explorer.api.model.response.address.AddressFilterResponse; | ||
import org.cardanofoundation.explorer.api.model.response.contract.ContractFilterResponse; | ||
import org.cardanofoundation.explorer.common.entity.ledgersync.Address; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface AddressMapper { | ||
|
||
ContractFilterResponse fromAddressToContractFilter(Address address); | ||
|
||
// @Mapping(target = "stakeAddress", source = "stakeAddress.view") | ||
// AddressResponse fromAddress(Address address); | ||
AddressResponse fromAddress(Address address); | ||
|
||
AddressFilterResponse fromAddressToFilterResponse(Address address); | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...a/org/cardanofoundation/explorer/api/repository/ledgersync/AddressTxAmountRepository.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,59 @@ | ||
package org.cardanofoundation.explorer.api.repository.ledgersync; | ||
|
||
|
||
import java.math.BigInteger; | ||
import java.sql.Timestamp; | ||
import java.time.LocalDate; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import org.cardanofoundation.explorer.api.projection.MinMaxProjection; | ||
import org.cardanofoundation.explorer.common.entity.compositeKey.AddressTxAmountId; | ||
import org.cardanofoundation.explorer.common.entity.ledgersync.AddressTxAmount; | ||
|
||
public interface AddressTxAmountRepository | ||
extends JpaRepository<AddressTxAmount, AddressTxAmountId> { | ||
|
||
@Query( | ||
value = | ||
""" | ||
select :fromBalance + coalesce(min(calculated_balances.sum_balance), 0) as minVal, | ||
:fromBalance + coalesce(max(calculated_balances.sum_balance), 0) as maxVal | ||
from (select sum(ata.quantity) over (order by ata.slot rows unbounded PRECEDING) as sum_balance | ||
from address_tx_amount ata | ||
where ata.address = :address | ||
and ata.unit = 'lovelace' | ||
and ata.block_time > :fromDate | ||
and ata.block_time <= :toDate) as calculated_balances | ||
""", nativeQuery = true) | ||
MinMaxProjection findMinMaxBalanceByAddress( | ||
@Param("address") String address, | ||
@Param("fromBalance") BigInteger fromBalance, | ||
@Param("fromDate") Long fromDate, | ||
@Param("toDate") Long toDate); | ||
|
||
|
||
@Query( | ||
"SELECT sum(addressTxBalance.quantity) FROM AddressTxAmount addressTxBalance" | ||
+ " WHERE addressTxBalance.address = :address" | ||
+ " AND addressTxBalance.blockTime > :from and addressTxBalance.blockTime <= :to") | ||
Optional<BigInteger> getBalanceByAddressAndTime(@Param("address") String address, | ||
@Param("from") Long from, | ||
@Param("to") Long to); | ||
|
||
|
||
@Query( | ||
value = | ||
""" | ||
SELECT sum(ata.quantity) | ||
FROM AddressTxAmount ata | ||
WHERE ata.address = :address | ||
AND ata.unit = 'lovelace' | ||
AND ata.blockTime <= :to | ||
""") | ||
Optional<BigInteger> sumBalanceByAddress( | ||
@Param("address") String address, @Param("to") Long to); | ||
} |
13 changes: 13 additions & 0 deletions
13
...va/org/cardanofoundation/explorer/api/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,13 @@ | ||
package org.cardanofoundation.explorer.api.repository.ledgersync; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import org.cardanofoundation.explorer.common.entity.ledgersync.AddressTxCount; | ||
|
||
public interface AddressTxCountRepository extends JpaRepository<AddressTxCount, String> { | ||
|
||
List<AddressTxCount> findAllByAddressIn(Collection<String> addressList); | ||
} |
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
10 changes: 10 additions & 0 deletions
10
.../cardanofoundation/explorer/api/repository/ledgersync/LatestAddressBalanceRepository.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,10 @@ | ||
package org.cardanofoundation.explorer.api.repository.ledgersync; | ||
|
||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import org.cardanofoundation.explorer.common.entity.compositeKey.AddressBalanceId; | ||
import org.cardanofoundation.explorer.common.entity.ledgersync.LatestAddressBalance; | ||
|
||
public interface LatestAddressBalanceRepository extends JpaRepository<LatestAddressBalance, AddressBalanceId>{ | ||
} |
Oops, something went wrong.