Add pass logic.

Change-Id: Ibd0a8d67fd3d73435761ca2c495265eaf51a06d5
pull/1268/head
Jaehwa Noh 9 months ago
parent 6ab93572fe
commit 9b0946ae12

@ -69,6 +69,10 @@ internal class DefaultSearchContentsRepository @Inject constructor(
return@forEach return@forEach
} }
if (oldNewsResourceFtsEntities.firstOrNull() == newsResourceFtsEntity) {
return@forEach
}
newsResourceFtsDao.update( newsResourceFtsDao.update(
title = newsResourceFtsEntity.title, title = newsResourceFtsEntity.title,
content = newsResourceFtsEntity.content, content = newsResourceFtsEntity.content,
@ -78,20 +82,24 @@ internal class DefaultSearchContentsRepository @Inject constructor(
topicDao.getOneOffTopicEntities().forEach { topicEntity -> topicDao.getOneOffTopicEntities().forEach { topicEntity ->
val oldTopicFtsEntities = topicFtsDao.getFtsEntitiesById(topicEntity.id) val oldTopicFtsEntities = topicFtsDao.getFtsEntitiesById(topicEntity.id)
val size = oldTopicFtsEntities.size val size = oldTopicFtsEntities.size
val topicFtsEntity = topicEntity.asFtsEntity()
if (size == 0) { if (size == 0) {
topicFtsDao.insert(topicEntity.asFtsEntity()) topicFtsDao.insert(topicFtsEntity)
return@forEach return@forEach
} }
// Do it for migration, multiple same id entity exists in the fts database. // Do it for migration, multiple same id entity exists in the fts database.
if (size > 1) { if (size > 1) {
topicFtsDao.deleteById(topicEntity.id) topicFtsDao.deleteById(topicEntity.id)
topicFtsDao.insert(topicEntity.asFtsEntity()) topicFtsDao.insert(topicFtsEntity)
return@forEach return@forEach
} }
if (oldTopicFtsEntities.firstOrNull() == topicFtsEntity) return@forEach
topicFtsDao.update( topicFtsDao.update(
name = topicEntity.name, name = topicEntity.name,
shortDescription = topicEntity.shortDescription, shortDescription = topicEntity.shortDescription,

Loading…
Cancel
Save