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

This commit is contained in:
Torsten Grote
2023-10-31 13:13:38 -03:00
parent b28d2ecd5b
commit 4a01b02fa6
2 changed files with 31 additions and 0 deletions

View File

@@ -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.
*/