mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Repositories & categories (filter out) arguments to Product query builder
This commit is contained in:
parent
b52e89512e
commit
ccd72d3944
@ -124,6 +124,8 @@ interface ProductDao : BaseDao<Product> {
|
||||
updates: Boolean,
|
||||
searchQuery: String,
|
||||
section: Section,
|
||||
filteredOutRepos: Set<String> = emptySet(),
|
||||
filteredOutCategories: Set<String> = emptySet(),
|
||||
order: Order,
|
||||
ascending: Boolean = false,
|
||||
numberOfItems: Int = 0,
|
||||
@ -178,14 +180,22 @@ interface ProductDao : BaseDao<Product> {
|
||||
ON $TABLE_PRODUCT.$ROW_PACKAGE_NAME = $TABLE_INSTALLED.$ROW_PACKAGE_NAME"""
|
||||
|
||||
// Merge the matching category
|
||||
if (section is Section.Category) {
|
||||
builder += """JOIN $TABLE_CATEGORY_NAME AS $TABLE_CATEGORY
|
||||
ON $TABLE_PRODUCT.$ROW_PACKAGE_NAME = $TABLE_CATEGORY.$ROW_PACKAGE_NAME"""
|
||||
}
|
||||
builder += """JOIN $TABLE_CATEGORY_NAME AS $TABLE_CATEGORY
|
||||
ON $TABLE_PRODUCT.$ROW_PACKAGE_NAME = $TABLE_CATEGORY.$ROW_PACKAGE_NAME"""
|
||||
|
||||
// Filter only active repositories
|
||||
builder += """WHERE $TABLE_REPOSITORY.$ROW_ENABLED != 0"""
|
||||
|
||||
// Filter out repositories
|
||||
if (filteredOutRepos.isNotEmpty()) {
|
||||
builder += "AND $TABLE_PRODUCT.$ROW_REPOSITORY_ID NOT IN(${filteredOutRepos.joinToString { "'$it'" }})"
|
||||
}
|
||||
|
||||
// Filter out categories
|
||||
if (filteredOutCategories.isNotEmpty()) {
|
||||
builder += "AND $TABLE_CATEGORY.$ROW_LABEL NOT IN(${filteredOutCategories.joinToString { "'$it'" }})"
|
||||
}
|
||||
|
||||
// Filter only the selected repository/category
|
||||
if (section is Section.Category) {
|
||||
builder += "AND $TABLE_CATEGORY.$ROW_LABEL = ?"
|
||||
|
Loading…
x
Reference in New Issue
Block a user