Fix GetFoldersWithFeeds tests...

This commit is contained in:
Shinokuni 2024-04-27 21:20:35 +02:00
parent 9f87077945
commit 2c105f596a
2 changed files with 14 additions and 7 deletions

View File

@ -30,7 +30,6 @@ class GetFoldersWithFeeds(
} else { } else {
null null
} }
}, },
valueTransform = { valueTransform = {
Feed( Feed(
@ -52,7 +51,7 @@ class GetFoldersWithFeeds(
} }
} }
foldersWithFeeds foldersWithFeeds.toSortedMap(nullsLast(Folder::compareTo))
} }
} }
} }

View File

@ -9,11 +9,19 @@ import kotlinx.coroutines.flow.Flow
@Dao @Dao
interface NewFolderDao : NewBaseDao<Folder> { interface NewFolderDao : NewBaseDao<Folder> {
@Query("Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl, " + @Query("""
"Feed.siteUrl As feedSiteUrl, Feed.description as feedDescription, Feed.account_id As accountId, " + Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl,
"Folder.id As folderId, Folder.name As folderName, 0 as unreadCount " + Feed.siteUrl As feedSiteUrl, Feed.description as feedDescription,
" From Feed Left Join Folder On Folder.id = Feed.folder_id " + Folder.id As folderId, Folder.name As folderName, Feed.account_id as accountId
"Where Feed.folder_id is NULL OR Feed.folder_id is NOT NULL And Feed.account_id = :accountId Group By Feed.id") From Feed Left Join Folder On Folder.id = Feed.folder_id
Where Feed.folder_id is NULL OR Feed.folder_id is NOT NULL And Feed.id is NULL Or Feed.id is NOT NULL And Feed.account_id = :accountId Group By Feed.id
UNION ALL
Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl,
Feed.siteUrl As feedSiteUrl, Feed.description as feedDescription,
Folder.id As folderId, Folder.name As folderName, Folder.account_id as accountId
From Folder Left Join Feed On Folder.id = Feed.folder_id
Where Feed.id is NULL And Folder.account_id = :accountId
""")
fun selectFoldersAndFeeds(accountId: Int): Flow<List<FolderWithFeed>> fun selectFoldersAndFeeds(accountId: Int): Flow<List<FolderWithFeed>>
@Query("Select * From Folder Where account_id = :accountId") @Query("Select * From Folder Where account_id = :accountId")