Avoid notification for hourly rate when there is not much data

perftest
Laurent 3 years ago
parent 9c99ef9c35
commit 887dea91da
  1. 15
      app/src/main/java/net/pokeranalytics/android/calculus/ReportWhistleBlower.kt
  2. 8
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  3. 8
      app/src/main/java/net/pokeranalytics/android/ui/view/rows/StaticReport.kt

@ -9,6 +9,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.pokeranalytics.android.calculus.optimalduration.CashGameOptimalDurationCalculator
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.LiveOnline
import net.pokeranalytics.android.model.realm.*
import net.pokeranalytics.android.ui.view.rows.StaticReport
@ -201,7 +202,7 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co
val nameSeparator = " "
for (stat in result.options.stats) {
for (stat in staticReport.performanceStats) {
// Timber.d("analyse stat: $stat for report: $staticReport")
@ -222,7 +223,8 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co
val performanceQuery = computedResults.group.query
val performanceName = performanceQuery.getName(this.context, nameSeparator)
// Timber.d("Best computed = $performanceName, ${computedResults.computedStat(Stat.NET_RESULT)?.value}")
val count = computedResults.computedStat(Stat.NUMBER_OF_GAMES)?.value?.toInt() ?: throw PAIllegalStateException("Number of games not found")
val notify = !(stat.hasEarlyVariance && count < 10)
var storePerf = true
currentPerf?.let {
@ -243,7 +245,10 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co
currentPerf.objectId = performanceQuery.objectId
currentPerf.customFieldId = customField?.id
}
this.whistleBlower.notify(currentPerf)
if (notify) {
this.whistleBlower.notify(currentPerf)
}
}
}
@ -258,7 +263,9 @@ class ReportTask(private var whistleBlower: ReportWhistleBlower, var context: Co
null
)
realm.executeTransaction { it.copyToRealm(performance) }
this.whistleBlower.notify(performance)
if (notify) {
this.whistleBlower.notify(performance)
}
}
} ?: run { // if there is no max but a now irrelevant Performance, we delete it

@ -319,6 +319,14 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres
}
}
val hasEarlyVariance: Boolean
get() {
return when (this) {
HOURLY_RATE, AVERAGE, AVERAGE_NET_BB, AVERAGE_BUYIN, AVERAGE_HOURLY_DURATION -> true
else -> false
}
}
private val hasProgressValues: Boolean
get() {
return when (this) {

@ -107,6 +107,14 @@ sealed class StaticReport(override var uniqueIdentifier: Int) : RowRepresentable
}
val stats: List<Stat>
get() {
return when (this) {
OptimalDuration -> listOf(Stat.AVERAGE_NET_BB)
else -> listOf(Stat.NET_RESULT, Stat.HOURLY_RATE, Stat.NUMBER_OF_GAMES)
}
}
val performanceStats: List<Stat>
get() {
return when (this) {
OptimalDuration -> listOf(Stat.AVERAGE_NET_BB)

Loading…
Cancel
Save