-
Notifications
You must be signed in to change notification settings - Fork 25
Minor fixes #404
base: kraken
Are you sure you want to change the base?
Minor fixes #404
Conversation
trema96
commented
Jun 13, 2022
•
edited
Loading
edited
- Fix InternalDAO get with rev
- Make purge(Collection) reactive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before refactoring the GenericDAO, I would like to be sure we are not breaking anything, as this is one of the most used components in BackEnd.
Could you add a unit test to ensure the behaviour of purge method is still the same and do some test in acceptance environment ?
@@ -291,17 +290,16 @@ abstract class GenericDAOImpl<T : StoredDocument>( | |||
} | |||
} | |||
|
|||
// This function is not reactive, but it doesn't seem to be used at all anyway... | |||
override suspend fun purge(entities: Collection<T>) { | |||
override suspend fun purge(entities: Collection<T>): Flow<DocIdentifier> = flow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method returns a Flow, it should not be a suspend function anymore.
afterDelete(entity) | ||
} | ||
val entitiesById = entities.associateBy { it.id } | ||
val bulkDeleteResults = client.bulkDelete(entities.map { beforeDelete(it) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do it as a one-line code, this way :
emitAll(client.bulkDelete(entities.map { beforeDelete(it) })
.onEach { r -> entitiesById[r.id]?.let { afterDelete(it) } }
.map { updateResult -> DocIdentifier(updateResult.id, updateResult.rev) })