Add: Categories field to Product table

This commit is contained in:
machiav3lli 2022-02-18 02:51:39 +01:00
parent 2c1a542b0f
commit d31dd0c675
4 changed files with 5 additions and 2 deletions

View File

@ -23,6 +23,7 @@ const val ROW_COMPATIBLE = "compatible"
const val ROW_ICON = "icon" const val ROW_ICON = "icon"
const val ROW_METADATA_ICON = "metadataIcon" const val ROW_METADATA_ICON = "metadataIcon"
const val ROW_RELEASES = "releases" const val ROW_RELEASES = "releases"
const val ROW_CATEGORIES = "categories"
const val ROW_VERSION = "version" const val ROW_VERSION = "version"
const val ROW_SIGNATURE = "signature" const val ROW_SIGNATURE = "signature"
const val ROW_ID = "_id" const val ROW_ID = "_id"

View File

@ -128,7 +128,7 @@ interface ProductDao : BaseDao<Product> {
product.${ROW_COMPATIBLE} != 0 AND product.${ROW_VERSION_CODE} > product.${ROW_COMPATIBLE} != 0 AND product.${ROW_VERSION_CODE} >
COALESCE(installed.${ROW_VERSION_CODE}, 0xffffffff) AND $signatureMatches) COALESCE(installed.${ROW_VERSION_CODE}, 0xffffffff) AND $signatureMatches)
AS ${ROW_CAN_UPDATE}, product.${ROW_COMPATIBLE}, AS ${ROW_CAN_UPDATE}, product.${ROW_COMPATIBLE},
product.${ROW_ICON}, product.${ROW_METADATA_ICON}, product.${ROW_RELEASES},""" product.${ROW_ICON}, product.${ROW_METADATA_ICON}, product.${ROW_RELEASES}, product.${ROW_CATEGORIES},"""
// Calculate the matching score with the search query // Calculate the matching score with the search query
if (searchQuery.isNotEmpty()) { if (searchQuery.isNotEmpty()) {
@ -294,6 +294,7 @@ interface ProductTempDao : BaseDao<ProductTemp> {
icon = it.icon icon = it.icon
metadataIcon = it.metadataIcon metadataIcon = it.metadataIcon
releases = it.releases releases = it.releases
categories = it.categories
} }
}) })
it.categories.forEach { category -> it.categories.forEach { category ->

View File

@ -21,7 +21,7 @@ import kotlinx.coroutines.launch
CategoryTemp::class, CategoryTemp::class,
Installed::class, Installed::class,
Lock::class Lock::class
], version = 2 ], version = 3
) )
@TypeConverters(Converters::class) @TypeConverters(Converters::class)
abstract class DatabaseX : RoomDatabase() { abstract class DatabaseX : RoomDatabase() {

View File

@ -20,6 +20,7 @@ open class Product {
var icon = "" var icon = ""
var metadataIcon = "" var metadataIcon = ""
var releases: List<Release> = emptyList() var releases: List<Release> = emptyList()
var categories: List<String> = emptyList()
// TODO Remove in next iteration // TODO Remove in next iteration
@ColumnInfo(typeAffinity = ColumnInfo.BLOB) @ColumnInfo(typeAffinity = ColumnInfo.BLOB)