Skip to content

Commit 52c0d7a

Browse files
committed
Remove Insert function
- Insert is only used in test. - Upsert do same thing as Insert. Change-Id: Ib5f8e693e71c895b83e43f6b51cebdc698bf744b
1 parent 61f0adf commit 52c0d7a

File tree

2 files changed

+0
-21
lines changed
  • core

2 files changed

+0
-21
lines changed

core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/testdoubles/TestNewsResourceDao.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,6 @@ class TestNewsResourceDao : NewsResourceDao {
9292
result.map { it.entity.id }
9393
}
9494

95-
override suspend fun insertOrIgnoreNewsResources(
96-
entities: List<NewsResourceEntity>,
97-
): List<Long> {
98-
entitiesStateFlow.update { oldValues ->
99-
// Old values come first so new values don't overwrite them
100-
(oldValues + entities)
101-
.distinctBy(NewsResourceEntity::id)
102-
.sortedWith(
103-
compareBy(NewsResourceEntity::publishDate).reversed(),
104-
)
105-
}
106-
// Assume no conflicts on insert
107-
return entities.map { it.id.toLong() }
108-
}
109-
11095
override suspend fun upsertNewsResources(newsResourceEntities: List<NewsResourceEntity>) {
11196
entitiesStateFlow.update { oldValues ->
11297
// New values come first so they overwrite old values

core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDao.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ interface NewsResourceDao {
9696
filterNewsIds: Set<String> = emptySet(),
9797
): Flow<List<String>>
9898

99-
/**
100-
* Inserts [entities] into the db if they don't exist, and ignores those that do
101-
*/
102-
@Insert(onConflict = OnConflictStrategy.IGNORE)
103-
suspend fun insertOrIgnoreNewsResources(entities: List<NewsResourceEntity>): List<Long>
104-
10599
/**
106100
* Inserts or updates [newsResourceEntities] in the db under the specified primary keys
107101
*/

0 commit comments

Comments
 (0)