-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add currencies query to the transactions repository
- Loading branch information
Showing
9 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
11 changes: 3 additions & 8 deletions
11
core/src/main/kotlin/me/madhead/tyzenhaus/core/service/GroupCurrenciesService.kt
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,22 +1,17 @@ | ||
package me.madhead.tyzenhaus.core.service | ||
|
||
import me.madhead.tyzenhaus.repository.BalanceRepository | ||
import me.madhead.tyzenhaus.repository.TransactionRepository | ||
|
||
/** | ||
* Lists currencies used in transactions of the group. | ||
*/ | ||
class GroupCurrenciesService( | ||
private val balanceRepository: BalanceRepository, | ||
private val transactionRepository: TransactionRepository | ||
) { | ||
/** | ||
* Lists currencies used in transactions of the [group]. | ||
*/ | ||
fun groupCurrencies(group: Long): List<String>? { | ||
return balanceRepository | ||
.get(group) | ||
?.balance | ||
?.keys | ||
?.takeUnless { it.isEmpty() } | ||
?.toList() | ||
return transactionRepository.groupCurrencies(group).takeUnless { it.isEmpty() } | ||
} | ||
} |
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
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
1 change: 1 addition & 0 deletions
1
repository/postgresql/src/main/sql/transaction-add-group-id-index.sql
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 @@ | ||
CREATE INDEX transaction_group_id_hash ON transaction USING HASH (group_id); |
1 change: 1 addition & 0 deletions
1
repository/postgresql/src/main/sql/transaction-remove-group-id-index.sql
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 @@ | ||
DROP INDEX transaction_group_id_hash; |
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