Skip to content

Commit

Permalink
skip inserting link twice
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed Dec 15, 2023
1 parent 673d539 commit 9733521
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,20 @@ class TableauxModel(
}).foldLeft(Future(())) {
{
case (future, (table, column, id)) => {
future.flatMap(_ => {
updateOrReplaceValue(table, column.id, id, replacingRowId, false, maybeTransaction = t)
}).map(_ => ())
for {
_ <- future
linkedIds <- retrieveCurrentLinkIds(table, column, id)

_ <-
if (!linkedIds.contains(replacingRowId)) {
updateOrReplaceValue(table, column.id, id, replacingRowId, false, maybeTransaction = t)
} else {
logger.info(
s"skip adding link ${replacingRowId} to: ${table.id} ${column.id} $id because it is already linked"
)
Future.successful(())
}
} yield ()
}
}
}
Expand Down

0 comments on commit 9733521

Please sign in to comment.