From 4b2e9c22a3132ee6bc394cdcebadb7f6bd57278d Mon Sep 17 00:00:00 2001 From: avalin Date: Mon, 10 Jun 2024 10:59:11 +0200 Subject: [PATCH] Fix getWonNotifications --- Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt | 4 ++-- .../main/kotlin/allin/data/postgres/PostgresBetDataSource.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt index 8a8f1dd..d50d235 100644 --- a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt @@ -143,11 +143,11 @@ class MockBetDataSource(private val mockData: MockDataSource.MockData) : BetData } } - override fun getWonNotifications(username: String): List { + override fun getWonNotifications(userid: String): List { return bets.map { bet -> val notification = resultNotifications.find { it.first == bet.id } ?: return@map null val result = results.find { it.betId == bet.id } ?: return@map null - val participation = participations.find { it.username == username && it.betId == bet.id } + val participation = participations.find { it.userId == userid && it.betId == bet.id } ?: return@map null if (participation.answer == result.result) { diff --git a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt index 23f9bba..30854d4 100644 --- a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt @@ -117,7 +117,7 @@ class PostgresBetDataSource(private val database: Database) : BetDataSource { database.participations .filter { - (it.id eq userid) and + (it.userid eq userid) and (it.betId eq notif.betId) } .mapNotNull { participation ->