Merge branch 'dev' of gitlab.com:stax-river/poker-analytics into dev

feature/top10
Aurelien Hubert 7 years ago
commit e4c1aeec5b
  1. 3
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  2. 28
      app/src/main/java/net/pokeranalytics/android/model/migrations/Patcher.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  4. 1
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  5. 3
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SessionFragment.kt

@ -9,6 +9,7 @@ import io.realm.RealmConfiguration
import io.realm.kotlin.where import io.realm.kotlin.where
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import net.pokeranalytics.android.model.migrations.Patcher
import net.pokeranalytics.android.model.migrations.PokerAnalyticsMigration import net.pokeranalytics.android.model.migrations.PokerAnalyticsMigration
import net.pokeranalytics.android.model.realm.Session import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.model.utils.Seed import net.pokeranalytics.android.model.utils.Seed
@ -53,6 +54,8 @@ class PokerAnalyticsApplication : Application() {
Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}") Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}")
//this.createFakeSessions() //this.createFakeSessions()
} }
Patcher.patchBreaks()
} }
/** /**

@ -0,0 +1,28 @@
package net.pokeranalytics.android.model.migrations
import io.realm.Realm
import net.pokeranalytics.android.model.realm.SessionSet
class Patcher {
companion object {
fun patchBreaks() {
val realm = Realm.getDefaultInstance()
val sets = realm.where(SessionSet::class.java).findAll()
realm.executeTransaction {
sets.forEach {
it.computeStats()
}
}
realm.close()
}
}
}

@ -779,7 +779,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
cgBigBlind = null cgBigBlind = null
} }
SessionRow.BREAK_TIME -> { SessionRow.BREAK_TIME -> {
this.breakDuration = if (value != null) (value as String).toLong() * 60 * 1000 else 0 this.breakDuration = (value as Double? ?: 0.0).toLong() * 60 * 1000
} }
SessionRow.BUY_IN -> { SessionRow.BUY_IN -> {
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java)

@ -63,6 +63,7 @@ open class SessionSet() : RealmObject(), Timed, Filterable {
this.ratedNet = this.sessions?.sumByDouble { it.computableResult?.ratedNet ?: 0.0 } ?: 0.0 this.ratedNet = this.sessions?.sumByDouble { it.computableResult?.ratedNet ?: 0.0 } ?: 0.0
this.estimatedHands = this.sessions?.sumByDouble { it.estimatedHands } ?: 0.0 this.estimatedHands = this.sessions?.sumByDouble { it.estimatedHands } ?: 0.0
this.bbNet = this.sessions?.sumByDouble { it.bbNet } ?: 0.0 this.bbNet = this.sessions?.sumByDouble { it.bbNet } ?: 0.0
this.breakDuration = this.sessions?.max("breakDuration")?.toLong() ?: 0L
} }
/** /**

@ -115,8 +115,7 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate {
sessionAdapter.refreshRow(row) sessionAdapter.refreshRow(row)
when (row) { when (row) {
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT, SessionRow.BUY_IN, SessionRow.TIPS, SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT, SessionRow.BUY_IN, SessionRow.TIPS,
SessionRow.START_DATE, SessionRow.END_DATE, SessionRow.BANKROLL -> updateSessionUI() SessionRow.START_DATE, SessionRow.END_DATE, SessionRow.BANKROLL, SessionRow.BREAK_TIME -> updateSessionUI()
SessionRow.BREAK_TIME -> this.sessionAdapter.notifyDataSetChanged()
} }
} }

Loading…
Cancel
Save