|
|
|
|
@ -66,22 +66,26 @@ open class Filter : RealmObject() { |
|
|
|
|
private set |
|
|
|
|
|
|
|
|
|
fun createOrUpdateFilterConditions(filterConditionRows: ArrayList<QueryCondition>) { |
|
|
|
|
val casted = arrayListOf<QueryCondition>() |
|
|
|
|
println("list of querys saving: ${filterConditionRows.map { it.id }}") |
|
|
|
|
println("list of querys previous: ${this.filterConditions.map { it.queryCondition.id }}") |
|
|
|
|
filterConditionRows |
|
|
|
|
.map { |
|
|
|
|
it.id |
|
|
|
|
it.filterSectionRow |
|
|
|
|
} |
|
|
|
|
.distinct() |
|
|
|
|
.forEach { filterName-> |
|
|
|
|
filterConditionRows |
|
|
|
|
.filter { |
|
|
|
|
it.id == filterName |
|
|
|
|
it.filterSectionRow == filterName |
|
|
|
|
} |
|
|
|
|
.apply { |
|
|
|
|
|
|
|
|
|
println("list of querys: ${this.map { it.id }}") |
|
|
|
|
val casted = arrayListOf<QueryCondition>() |
|
|
|
|
casted.addAll(this) |
|
|
|
|
val newFilterCondition = FilterCondition(casted) |
|
|
|
|
val previousCondition = filterConditions.filter { |
|
|
|
|
it.sectionName == newFilterCondition.filterName |
|
|
|
|
it.filterName == newFilterCondition.filterName |
|
|
|
|
} |
|
|
|
|
filterConditions.removeAll(previousCondition) |
|
|
|
|
filterConditions.add(newFilterCondition) |
|
|
|
|
@ -90,20 +94,19 @@ open class Filter : RealmObject() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun countBy(filterCategoryRow: FilterCategoryRow): Int { |
|
|
|
|
val sections = filterCategoryRow.filterSectionRows |
|
|
|
|
return filterConditions.count { |
|
|
|
|
sections.contains(FilterSectionRow.valueOf(it.sectionName ?: throw PokerAnalyticsException.FilterElementUnknownSectionName)) |
|
|
|
|
} |
|
|
|
|
val sections = filterCategoryRow.filterSectionRows.map { it.name } |
|
|
|
|
println("list of sections $sections") |
|
|
|
|
val savedSections = filterConditions.filter { sections.contains(it.sectionName) }.flatMap { it.queryCondition.id } |
|
|
|
|
println("list of savedSections $savedSections") |
|
|
|
|
return savedSections.size |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun contains(filterElementRow: QueryCondition): Boolean { |
|
|
|
|
val filtered = filterConditions.filter { |
|
|
|
|
it.filterName == filterElementRow.id |
|
|
|
|
} |
|
|
|
|
if (filtered.isEmpty()) { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return filterElementRow.contains(filtered) |
|
|
|
|
println("list of saved queries ${filterConditions.map { it.queryCondition.id }}") |
|
|
|
|
println("list of contains ${filterElementRow.id}") |
|
|
|
|
val contained = filterConditions.flatMap{ it.queryCondition.id }.contains(filterElementRow.id.first()) |
|
|
|
|
println("list of : $contained") |
|
|
|
|
return contained |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -111,7 +114,7 @@ open class Filter : RealmObject() { |
|
|
|
|
*/ |
|
|
|
|
fun loadValueForElement(filterElementRow: QueryCondition) { |
|
|
|
|
val filtered = filterConditions.filter { |
|
|
|
|
it.filterName == filterElementRow.id |
|
|
|
|
it.queryCondition == filterElementRow.id |
|
|
|
|
} |
|
|
|
|
if (filtered.isNotEmpty()) { |
|
|
|
|
return filterElementRow.updateValueMap(filtered.first()) |
|
|
|
|
|