[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: avoid confusing helper
From: |
gnunet |
Subject: |
[libeufin] branch master updated: avoid confusing helper |
Date: |
Mon, 01 Jun 2020 17:10:16 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new c7f37ec avoid confusing helper
c7f37ec is described below
commit c7f37ecfb619cc1426d9b76c7285df4bbc499b8f
Author: MS <ms@taler.net>
AuthorDate: Mon Jun 1 17:10:12 2020 +0200
avoid confusing helper
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 4 ----
nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 15 ++++++++++-----
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 7979f73..7dbf7b0 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -61,10 +61,6 @@ object TalerIncomingPayments : LongIdTable() {
val refunded = bool("refunded").default(false)
}
-fun LongEntityClass<*>.getLast(): Long {
- return this.all().maxBy { it.id }?.id?.value ?: -1
-}
-
class TalerIncomingPaymentEntity(id: EntityID<Long>) : LongEntity(id) {
companion object :
LongEntityClass<TalerIncomingPaymentEntity>(TalerIncomingPayments) {
override fun new(init: TalerIncomingPaymentEntity.() -> Unit):
TalerIncomingPaymentEntity {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 7b21121..9d1c5f8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -351,7 +351,7 @@ suspend fun talerAddIncoming(call: ApplicationCall): Unit {
*/
fun ingestTalerTransactions() {
fun ingestIncoming(subscriberAccount: NexusBankAccountEntity) {
- val latestIncomingPaymentId: Long =
TalerIncomingPaymentEntity.getLast()
+ val latestIncomingPayment = TalerIncomingPaymentEntity.all().maxBy {
it.payment.id.value }
RawBankTransactionEntity.find {
/** Those with exchange bank account involved */
RawBankTransactionsTable.bankAccount eq subscriberAccount.id.value
and
@@ -360,7 +360,10 @@ fun ingestTalerTransactions() {
/** Those that are booked */
(RawBankTransactionsTable.status eq "BOOK") and
/** Those that came later than the latest processed
payment */
-
(RawBankTransactionsTable.id.greater(latestIncomingPaymentId))
+ (RawBankTransactionsTable.id.greater(
+ if (latestIncomingPayment == null) 0
+ else latestIncomingPayment.payment.id.value
+ ))
}.forEach {
if (duplicatePayment(it)) {
logger.warn("Incoming payment already seen")
@@ -381,13 +384,15 @@ fun ingestTalerTransactions() {
}
}
}
-
}
fun ingestOutgoing(subscriberAccount: NexusBankAccountEntity) {
- val latestOutgoingPaymentId = TalerRequestedPaymentEntity.getLast()
+ val latestOutgoingPayment = TalerIncomingPaymentEntity.all().maxBy {
it.payment.id.value }
RawBankTransactionEntity.find {
/** Those that came after the last processed payment */
- RawBankTransactionsTable.id greater latestOutgoingPaymentId and
+ RawBankTransactionsTable.id.greater(
+ if (latestOutgoingPayment == null) 0
+ else latestOutgoingPayment.payment.id.value
+ ) and
/** Those involving the exchange bank account */
(RawBankTransactionsTable.bankAccount eq
subscriberAccount.id.value) and
/** Those that are outgoing */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: avoid confusing helper,
gnunet <=