|
|
|
@ -8,15 +8,20 @@ import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
import kotlinx.android.synthetic.main.fragment_calendar.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_calendar.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_stats.recyclerView |
|
|
|
import kotlinx.android.synthetic.main.fragment_stats.recyclerView |
|
|
|
import kotlinx.coroutines.* |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.Calculator |
|
|
|
import net.pokeranalytics.android.calculus.Calculator |
|
|
|
import net.pokeranalytics.android.calculus.Report |
|
|
|
|
|
|
|
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.Comparator |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
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.fragment.components.SessionObserverFragment |
|
|
|
import net.pokeranalytics.android.ui.view.CalendarTabs |
|
|
|
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 timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
@ -81,10 +86,47 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope { |
|
|
|
private fun launchStatComputation() { |
|
|
|
private fun launchStatComputation() { |
|
|
|
|
|
|
|
|
|
|
|
val comparator = Comparator.MONTH // returns all months |
|
|
|
val comparator = Comparator.MONTH // returns all months |
|
|
|
|
|
|
|
|
|
|
|
//val conditions = comparator.queryConditions |
|
|
|
//val conditions = comparator.queryConditions |
|
|
|
val conditions = listOf(QueryCondition.CASH, QueryCondition.TOURNAMENT) |
|
|
|
//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() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GlobalScope.launch { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val report = Calculator.computeStatsWithComparators(realm, conditions = listOf(filterMonth, filterYear), options = Calculator.Options()) |
|
|
|
|
|
|
|
Timber.d("Report results: ${report.results.size}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
report.results.firstOrNull()?.let { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val isEmpty = it.isEmpty |
|
|
|
|
|
|
|
val statValue = it.computedStat(Stat.NETRESULT)?.value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Timber.d("isEmpty: $isEmpty") |
|
|
|
|
|
|
|
Timber.d("statValue: $statValue") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
conditions.forEach { |
|
|
|
conditions.forEach { |
|
|
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
val realm = getRealm() |
|
|
|
@ -127,13 +169,12 @@ class CalendarFragment : SessionObserverFragment(), CoroutineScope { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Init UI |
|
|
|
* Init UI |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|