|
|
|
@ -12,7 +12,6 @@ import net.pokeranalytics.android.calculus.optimalduration.CashGameOptimalDurati |
|
|
|
import net.pokeranalytics.android.model.LiveOnline |
|
|
|
import net.pokeranalytics.android.model.LiveOnline |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.ui.view.rows.StaticReport |
|
|
|
import net.pokeranalytics.android.ui.view.rows.StaticReport |
|
|
|
import net.pokeranalytics.android.util.CrashLogging |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.extensions.formattedHourlyDuration |
|
|
|
import net.pokeranalytics.android.util.extensions.formattedHourlyDuration |
|
|
|
import timber.log.Timber |
|
|
|
import timber.log.Timber |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
@ -33,7 +32,7 @@ class ReportWhistleBlower(var context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
private val listeners: MutableList<NewPerformanceListener> = mutableListOf() |
|
|
|
private val listeners: MutableList<NewPerformanceListener> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
var paused: Boolean = false |
|
|
|
private var paused: Boolean = false |
|
|
|
|
|
|
|
|
|
|
|
private var timer: CountDownTimer? = null |
|
|
|
private var timer: CountDownTimer? = null |
|
|
|
|
|
|
|
|
|
|
|
@ -66,7 +65,6 @@ class ReportWhistleBlower(var context: Context) { |
|
|
|
// Timber.d(">>> Launch report") |
|
|
|
// Timber.d(">>> Launch report") |
|
|
|
|
|
|
|
|
|
|
|
if (paused) { |
|
|
|
if (paused) { |
|
|
|
CrashLogging.log("can't start reports comparisons because of paused state") |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -133,13 +131,10 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
|
|
|
|
|
|
|
|
private var cancelled = false |
|
|
|
private var cancelled = false |
|
|
|
|
|
|
|
|
|
|
|
var handler: (() -> Unit)? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val coroutineContext: CoroutineContext |
|
|
|
private val coroutineContext: CoroutineContext |
|
|
|
get() = Dispatchers.Default |
|
|
|
get() = Dispatchers.Default |
|
|
|
|
|
|
|
|
|
|
|
fun start() { |
|
|
|
fun start() { |
|
|
|
messages.add("Starting task...") |
|
|
|
|
|
|
|
launchReports() |
|
|
|
launchReports() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -147,8 +142,6 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
this.cancelled = true |
|
|
|
this.cancelled = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var messages: MutableList<String> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun launchReports() { |
|
|
|
private fun launchReports() { |
|
|
|
CoroutineScope(coroutineContext).launch { |
|
|
|
CoroutineScope(coroutineContext).launch { |
|
|
|
|
|
|
|
|
|
|
|
@ -197,18 +190,14 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun launchOptimalDuration(realm: Realm, report: StaticReport) { |
|
|
|
private fun launchOptimalDuration(realm: Realm, report: StaticReport) { |
|
|
|
LiveOnline.entries.forEach { key -> |
|
|
|
LiveOnline.values().forEach { key -> |
|
|
|
val duration = CashGameOptimalDurationCalculator.start(key.isLive) |
|
|
|
val duration = CashGameOptimalDurationCalculator.start(key.isLive) |
|
|
|
analyseOptimalDuration(realm, report, key, duration) |
|
|
|
analyseOptimalDuration(realm, report, key, duration) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.handler?.let { it() } |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun analyseDefaultReport(realm: Realm, staticReport: StaticReport, result: Report) { |
|
|
|
private fun analyseDefaultReport(realm: Realm, staticReport: StaticReport, result: Report) { |
|
|
|
|
|
|
|
|
|
|
|
messages.add("Analyse report $staticReport...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val nameSeparator = " " |
|
|
|
val nameSeparator = " " |
|
|
|
|
|
|
|
|
|
|
|
for (stat in result.options.stats) { |
|
|
|
for (stat in result.options.stats) { |
|
|
|
@ -228,7 +217,6 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
// Store if necessary, delete if necessary |
|
|
|
// Store if necessary, delete if necessary |
|
|
|
val bestComputedResults = result.max(stat) |
|
|
|
val bestComputedResults = result.max(stat) |
|
|
|
bestComputedResults?.let { computedResults -> |
|
|
|
bestComputedResults?.let { computedResults -> |
|
|
|
messages.add("found new perf...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val performanceQuery = computedResults.group.query |
|
|
|
val performanceQuery = computedResults.group.query |
|
|
|
val performanceName = performanceQuery.getName(this.context, nameSeparator) |
|
|
|
val performanceName = performanceQuery.getName(this.context, nameSeparator) |
|
|
|
@ -237,8 +225,6 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
|
|
|
|
|
|
|
|
var storePerf = true |
|
|
|
var storePerf = true |
|
|
|
currentPerf?.let { |
|
|
|
currentPerf?.let { |
|
|
|
messages.add("has current perf...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentPerf.name?.let { name -> |
|
|
|
currentPerf.name?.let { name -> |
|
|
|
if (computedResults.group.query.getName(this.context, nameSeparator) == name) { |
|
|
|
if (computedResults.group.query.getName(this.context, nameSeparator) == name) { |
|
|
|
storePerf = false |
|
|
|
storePerf = false |
|
|
|
@ -260,7 +246,6 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
messages.add("storePerf = $storePerf...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentPerf == null && storePerf) { |
|
|
|
if (currentPerf == null && storePerf) { |
|
|
|
val performance = Performance( |
|
|
|
val performance = Performance( |
|
|
|
@ -276,9 +261,6 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} ?: run { // if there is no max but a now irrelevant Performance, we delete it |
|
|
|
} ?: run { // if there is no max but a now irrelevant Performance, we delete it |
|
|
|
|
|
|
|
|
|
|
|
messages.add("deletes current perf if necessary: $currentPerf...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Timber.d("NO best computed value, current perf = $currentPerf ") |
|
|
|
// Timber.d("NO best computed value, current perf = $currentPerf ") |
|
|
|
currentPerf?.let { perf -> |
|
|
|
currentPerf?.let { perf -> |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
|