[db] Add DB query for getting repos an app is in

This commit is contained in:
Torsten Grote committed 2024-02-20 09:42:39 -03:00
1 parent b28d2ecd5b
commit 4a01b02fa6
2 files changed
+31

No files matched your search

@@ -70,6 +70,12 @@ public interface AppDao {
*/
public fun getApp(repoId: Long, packageName: String): App?
/**
* Returns a list of all enabled repositories identified by their [Repository.repoId]
* that contain the app identified by the given [packageName].
*/
public fun getRepositoryIdsForApp(packageName: String): List<Long>
/**
* Returns a limited number of apps with limited data.
* Apps without name, icon or summary are at the end (or excluded if limit is too small).
@@ -316,6 +322,11 @@ internal interface AppDaoInt : AppDao {
WHERE repoId = :repoId AND packageName = :packageName""")
override fun getApp(repoId: Long, packageName: String): App?
@Query("""SELECT repoId FROM ${AppMetadata.TABLE}
JOIN RepositoryPreferences AS pref USING (repoId)
WHERE pref.enabled = 1 AND packageName = :packageName""")
override fun getRepositoryIdsForApp(packageName: String): List<Long>
/**
* Used for diffing.
*/