|
|
|
|
@ -16,14 +16,9 @@ import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.calculus.Calculator |
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
import net.pokeranalytics.android.model.realm.FilterCondition |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.SessionObserverFragment |
|
|
|
|
import net.pokeranalytics.android.ui.view.CalendarTabs |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSectionRow |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -85,43 +80,22 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope { |
|
|
|
|
|
|
|
|
|
private fun launchStatComputation() { |
|
|
|
|
|
|
|
|
|
val comparator = Comparator.MONTH // returns all months |
|
|
|
|
//val conditions = comparator.queryConditions |
|
|
|
|
//val conditions = listOf(QueryCondition.CASH, QueryCondition.TOURNAMENT) |
|
|
|
|
|
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
calendar.set(Calendar.YEAR, 2018) |
|
|
|
|
calendar.set(Calendar.MONTH, Calendar.DECEMBER) |
|
|
|
|
|
|
|
|
|
val filterMonth = QueryCondition.MONTH() |
|
|
|
|
val filterElementRow = FilterElementRow.Month(calendar.get(Calendar.MONTH)) |
|
|
|
|
filterElementRow.filterSectionRow = FilterSectionRow.DYNAMIC_DATE |
|
|
|
|
val filterElement = FilterCondition(arrayListOf(filterElementRow)) |
|
|
|
|
filterMonth.updateValueMap(filterElement) |
|
|
|
|
|
|
|
|
|
val filterYear = QueryCondition.YEAR() |
|
|
|
|
val filterElementRow2 = FilterElementRow.Year(calendar.get(Calendar.YEAR)) |
|
|
|
|
filterElementRow2.filterSectionRow = FilterSectionRow.DYNAMIC_DATE |
|
|
|
|
val filterElement2 = FilterCondition(arrayListOf(filterElementRow2)) |
|
|
|
|
filterYear.updateValueMap(filterElement2) |
|
|
|
|
|
|
|
|
|
//comparator.queryConditions.first().updateValueMap() |
|
|
|
|
val comparator = Comparator.YEAR // returns all months |
|
|
|
|
|
|
|
|
|
GlobalScope.launch { |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
val report = Calculator.computeStatsWithComparators(realm, conditions = listOf(filterMonth, filterYear), options = Calculator.Options()) |
|
|
|
|
val report = Calculator.computeStatsWithComparators(realm, comparators = listOf(comparator), options = Calculator.Options()) |
|
|
|
|
Timber.d("Report results: ${report.results.size}") |
|
|
|
|
|
|
|
|
|
report.results.firstOrNull()?.let { |
|
|
|
|
report.results.forEach { |
|
|
|
|
|
|
|
|
|
val isEmpty = it.isEmpty |
|
|
|
|
val statValue = it.computedStat(Stat.NETRESULT)?.value |
|
|
|
|
|
|
|
|
|
Timber.d("isEmpty: $isEmpty") |
|
|
|
|
Timber.d("statValue: $statValue") |
|
|
|
|
|
|
|
|
|
val isEmpty = it.isEmpty |
|
|
|
|
val statValue = it.computedStat(Stat.NETRESULT)?.value |
|
|
|
|
Timber.d("isEmpty: $isEmpty / statValue: $statValue / Number of stats: ${it.numberOfStats()}") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|