|
|
|
@ -2,6 +2,10 @@ package net.pokeranalytics.android.calculus |
|
|
|
|
|
|
|
|
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
import net.pokeranalytics.android.calculus.Stat.* |
|
|
|
import net.pokeranalytics.android.calculus.Stat.* |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.comparison.combined |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.filter.name |
|
|
|
import net.pokeranalytics.android.model.realm.ComputableResult |
|
|
|
import net.pokeranalytics.android.model.realm.ComputableResult |
|
|
|
import net.pokeranalytics.android.model.realm.Filter |
|
|
|
import net.pokeranalytics.android.model.realm.Filter |
|
|
|
import net.pokeranalytics.android.model.realm.SessionSet |
|
|
|
import net.pokeranalytics.android.model.realm.SessionSet |
|
|
|
@ -60,9 +64,25 @@ class Calculator { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun computeStatsWithComparators(realm: Realm, comparators: List<Comparator> = listOf(), conditions: List<QueryCondition> = listOf(), options: Options): Report { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val computableGroups: MutableList<ComputableGroup> = mutableListOf() |
|
|
|
|
|
|
|
comparators.combined().forEach { comparatorConditions -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val allConditions = mutableListOf<QueryCondition>() |
|
|
|
|
|
|
|
allConditions.addAll(conditions) |
|
|
|
|
|
|
|
allConditions.addAll(comparatorConditions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val group = ComputableGroup(allConditions.name(), conditions) |
|
|
|
|
|
|
|
computableGroups.add(group) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Calculator.computeGroups(realm, computableGroups, options) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun computeStatsWithFilters(realm: Realm, filters: List<Filter>, options: Options): Report { |
|
|
|
fun computeStatsWithFilters(realm: Realm, filters: List<Filter>, options: Options): Report { |
|
|
|
|
|
|
|
|
|
|
|
var computableGroups: MutableList<ComputableGroup> = mutableListOf() |
|
|
|
val computableGroups: MutableList<ComputableGroup> = mutableListOf() |
|
|
|
filters.forEach { filter -> |
|
|
|
filters.forEach { filter -> |
|
|
|
|
|
|
|
|
|
|
|
val group = ComputableGroup(filter.name, filter.filterConditions.map { it.queryCondition }) |
|
|
|
val group = ComputableGroup(filter.name, filter.filterConditions.map { it.queryCondition }) |
|
|
|
|