Skip to content

Commit 0bd5561

Browse files
moritzkiefer-dacocreature
authored andcommitted
Fix party filter in expired reward query (#2129)
[ci] Signed-off-by: Moritz Kiefer <[email protected]> Co-authored-by: Moritz Kiefer <[email protected]>
1 parent 324ab70 commit 0bd5561

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/store/db/DbSvDsoStore.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,15 @@ class DbSvDsoStore(
518518
): Future[Seq[SvDsoStore.RoundBatch[TCId]]] = {
519519
val templateId = companionClass.typeId(companion)
520520
val opName = s"list${templateId.getEntityName}GroupedByRound"
521+
val partyFilter =
522+
if (ignoredParties.nonEmpty)
523+
(sql"and reward_party not in " ++ inClause(ignoredParties)).toActionBuilder
524+
else sql""
521525
waitUntilAcsIngested {
522526
for {
523527
result <- storage
524528
.query(
525-
sql"""
529+
(sql"""
526530
select reward_round, array_agg(contract_id)
527531
from dso_acs_store
528532
where store_id = $acsStoreId
@@ -531,13 +535,11 @@ class DbSvDsoStore(
531535
and assigned_domain = $domain
532536
and reward_party is not null -- otherwise index is not used
533537
and reward_round is not null -- otherwise index is not used
534-
and reward_party NOT IN (${ignoredParties
535-
.map(_.filterString)
536-
.mkString(",")})
538+
""" ++ partyFilter ++ sql"""
537539
group by reward_round
538540
order by reward_round asc
539541
limit ${sqlLimit(totalCouponsLimit)}
540-
""".as[(Long, Array[ContractId[ValidatorRewardCoupon]])],
542+
""").toActionBuilder.as[(Long, Array[ContractId[ValidatorRewardCoupon]])],
541543
opName,
542544
)
543545
} yield applyLimit(opName, totalCouponsLimit, result)

apps/sv/src/test/scala/org/lfdecentralizedtrust/splice/store/db/SvDsoStoreTest.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ abstract class SvDsoStoreTest extends StoreTest with HasExecutionContext {
654654
(1 to 3).map(_ => validatorFaucetCoupon(userParty(2), round = 3))
655655
val validatorFaucet1Closed = (1 to 3).map(_ => validatorFaucetCoupon(userParty(1), round = 2))
656656
val validatorFaucet2Closed = (1 to 3).map(_ => validatorFaucetCoupon(userParty(2), round = 2))
657+
val validatorFaucet3Closed = (1 to 3).map(_ => validatorFaucetCoupon(userParty(3), round = 2))
657658

658659
val validator1NotClosed = (1 to 3).map(_ => validatorRewardCoupon(round = 3, userParty(1)))
659660
val validator2NotClosed = (1 to 3).map(_ => validatorRewardCoupon(round = 3, userParty(2)))
@@ -675,7 +676,7 @@ abstract class SvDsoStoreTest extends StoreTest with HasExecutionContext {
675676
store <- mkStore()
676677
_ <- dummyDomain.create(closedRound)(store.multiDomainAcsStore)
677678
_ <- MonadUtil.sequentialTraverse(
678-
validatorFaucet1NotClosed ++ validatorFaucet2NotClosed ++ validatorFaucet1Closed ++ validatorFaucet2Closed
679+
validatorFaucet1NotClosed ++ validatorFaucet2NotClosed ++ validatorFaucet1Closed ++ validatorFaucet2Closed ++ validatorFaucet3Closed
679680
)(
680681
dummyDomain.create(_)(store.multiDomainAcsStore)
681682
)
@@ -702,7 +703,7 @@ abstract class SvDsoStoreTest extends StoreTest with HasExecutionContext {
702703
domain = dummyDomain,
703704
enableExpireValidatorFaucet = true,
704705
totalCouponsLimit = PageLimit.tryCreate(1000),
705-
ignoredExpiredRewardsPartyIds = Set(userParty(1)),
706+
ignoredExpiredRewardsPartyIds = Set(userParty(1), userParty(3)),
706707
)
707708
resultWithoutFaucet <- store.getExpiredCouponsInBatchesPerRoundAndCouponType(
708709
domain = dummyDomain,
@@ -735,7 +736,7 @@ abstract class SvDsoStoreTest extends StoreTest with HasExecutionContext {
735736
batch.validatorCoupons should have size 0
736737
batch.appCoupons should have size 0
737738
batch.svRewardCoupons should have size 0
738-
batch.validatorFaucets should have size 6
739+
batch.validatorFaucets should have size 9
739740
}
740741
resultWithIgnoredUserParty should have size 4
741742
forAll(resultWithIgnoredUserParty)(_.closedRoundNumber shouldBe 2)

0 commit comments

Comments
 (0)