mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Update state and proposals only on invalid items
Invalid items are those that are not ready, and not shown to the user. When changing metadata, it should only be changed, if the item was not already shown to the user.
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
package docspell.store.records
|
||||
|
||||
import cats.implicits._
|
||||
import cats.data.NonEmptyList
|
||||
import cats.effect.Sync
|
||||
import cats.implicits._
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
import docspell.common._
|
||||
@ -110,12 +111,16 @@ object RItem {
|
||||
def getCollective(itemId: Ident): ConnectionIO[Option[Ident]] =
|
||||
selectSimple(List(cid), table, id.is(itemId)).query[Ident].option
|
||||
|
||||
def updateState(itemId: Ident, itemState: ItemState): ConnectionIO[Int] =
|
||||
def updateState(
|
||||
itemId: Ident,
|
||||
itemState: ItemState,
|
||||
existing: NonEmptyList[ItemState]
|
||||
): ConnectionIO[Int] =
|
||||
for {
|
||||
t <- currentTime
|
||||
n <- updateRow(
|
||||
table,
|
||||
id.is(itemId),
|
||||
and(id.is(itemId), state.isIn(existing)),
|
||||
commas(state.setTo(itemState), updated.setTo(t))
|
||||
).update.run
|
||||
} yield n
|
||||
|
Reference in New Issue
Block a user