Renaming Result.netResult into Result.onlineNet

csv
Laurent 6 years ago
parent 97ed99750f
commit 420055ab1d
  1. 4
      app/build.gradle
  2. 2
      app/src/androidTest/java/net/pokeranalytics/android/components/SessionInstrumentedUnitTest.kt
  3. 2
      app/src/androidTest/java/net/pokeranalytics/android/unitTests/BankrollInstrumentedUnitTest.kt
  4. 4
      app/src/androidTest/java/net/pokeranalytics/android/unitTests/DeleteInstrumentedUnitTest.kt
  5. 2
      app/src/androidTest/java/net/pokeranalytics/android/unitTests/StatPerformanceUnitTest.kt
  6. 8
      app/src/androidTest/java/net/pokeranalytics/android/unitTests/StatsInstrumentedUnitTest.kt
  7. 2
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  8. 1
      app/src/main/java/net/pokeranalytics/android/model/migrations/PokerAnalyticsMigration.kt
  9. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/Result.kt
  10. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  11. 2
      app/src/main/java/net/pokeranalytics/android/util/csv/SessionCSVDescriptor.kt

@ -29,8 +29,8 @@ android {
applicationId "net.pokeranalytics.android" applicationId "net.pokeranalytics.android"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 48 versionCode 51
versionName "2.1.2" versionName "2.1.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

@ -30,7 +30,7 @@ open class SessionInstrumentedUnitTest : RealmInstrumentedUnitTest() {
session.numberOfTables = numberOfTable session.numberOfTables = numberOfTable
session.tableSize = tableSize session.tableSize = tableSize
session.startDate = startDate session.startDate = startDate
session.result?.netResult = netResult session.result?.onlineNet = netResult
val cal = Calendar.getInstance() // creates calendar val cal = Calendar.getInstance() // creates calendar
cal.time = startDate // sets calendar time/date cal.time = startDate // sets calendar time/date
cal.add(Calendar.HOUR_OF_DAY, endDate) // adds one hour cal.add(Calendar.HOUR_OF_DAY, endDate) // adds one hour

@ -28,7 +28,7 @@ class BankrollInstrumentedUnitTest : SessionInstrumentedUnitTest() {
// convenience extension // convenience extension
fun Session.Companion.testInstance(netResult: Double, startDate: Date, endDate: Date?): Session { fun Session.Companion.testInstance(netResult: Double, startDate: Date, endDate: Date?): Session {
val session: Session = newInstance(super.mockRealm, false) val session: Session = newInstance(super.mockRealm, false)
session.result?.netResult = netResult session.result?.onlineNet = netResult
session.startDate = startDate session.startDate = startDate
session.endDate = endDate session.endDate = endDate
return session return session

@ -33,8 +33,8 @@ class DeleteInstrumentedUnitTest : RealmInstrumentedUnitTest() {
s1.bankroll = br1 s1.bankroll = br1
s2.bankroll = br2 s2.bankroll = br2
s1.result?.netResult = 100.0 s1.result?.onlineNet = 100.0
s2.result?.netResult = 200.0 s2.result?.onlineNet = 200.0
realm.commitTransaction() realm.commitTransaction()

@ -28,7 +28,7 @@ class StatPerformanceUnitTest : SessionInstrumentedUnitTest() {
realm.commitTransaction() realm.commitTransaction()
val d1 = Date() val d1 = Date()
realm.where(Result::class.java).sum("netResult") realm.where(Result::class.java).sum("onlineNet")
val d2 = Date() val d2 = Date()
val duration = (d2.time - d1.time) val duration = (d2.time - d1.time)

@ -593,8 +593,8 @@ class StatsInstrumentedUnitTest : SessionInstrumentedUnitTest() {
b2.currency = c2 b2.currency = c2
s1.bankroll = b1 s1.bankroll = b1
s2.bankroll = b2 s2.bankroll = b2
s1.result?.netResult = 100.0 s1.result?.onlineNet = 100.0
s2.result?.netResult = 200.0 s2.result?.onlineNet = 200.0
} }
@ -629,8 +629,8 @@ class StatsInstrumentedUnitTest : SessionInstrumentedUnitTest() {
b2.currency = c2 b2.currency = c2
s1.bankroll = b1 s1.bankroll = b1
s2.bankroll = b2 s2.bankroll = b2
s1.result?.netResult = 100.0 s1.result?.onlineNet = 100.0
s2.result?.netResult = 200.0 s2.result?.onlineNet = 200.0
} }

@ -33,7 +33,7 @@ class PokerAnalyticsApplication : Application() {
Realm.init(this) Realm.init(this)
val realmConfiguration = RealmConfiguration.Builder() val realmConfiguration = RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME) .name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(7) .schemaVersion(8)
.migration(PokerAnalyticsMigration()) .migration(PokerAnalyticsMigration())
.initialData(Seed(this)) .initialData(Seed(this))
.build() .build()

@ -168,6 +168,7 @@ class PokerAnalyticsMigration : RealmMigration {
} }
schema.get("Session")?.addField("tournamentPrizepool", Double::class.java)?.setNullable("tournamentPrizepool", true) schema.get("Session")?.addField("tournamentPrizepool", Double::class.java)?.setNullable("tournamentPrizepool", true)
schema.get("Result")?.renameField("netResult", "onlineNet")
currentVersion++ currentVersion++
} }

@ -49,7 +49,7 @@ open class Result : RealmObject(), Filterable {
/** /**
* The net result * The net result
*/ */
var netResult: Double? = null var onlineNet: Double? = null
set(value) { set(value) {
var errorMessage: String? = null var errorMessage: String? = null
@ -118,7 +118,7 @@ open class Result : RealmObject(), Filterable {
val transactionsSum = transactions.sumByDouble { it.amount } val transactionsSum = transactions.sumByDouble { it.amount }
this.netResult?.let { this.onlineNet?.let {
this.net = it + transactionsSum this.net = it + transactionsSum
} ?: run { } ?: run {
val buyin = this.buyin ?: 0.0 val buyin = this.buyin ?: 0.0
@ -132,8 +132,8 @@ open class Result : RealmObject(), Filterable {
// val cashOut = this.cashout ?: 0.0 // val cashOut = this.cashout ?: 0.0
// this.net = cashOut - buyin + transactionsSum // this.net = cashOut - buyin + transactionsSum
// } else { // } else {
// val netResult = this.netResult ?: 0.0 // val onlineNet = this.onlineNet ?: 0.0
// this.net = netResult + transactionsSum // this.net = onlineNet + transactionsSum
// } // }
// Precompute results // Precompute results

@ -476,7 +476,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
val hasNetResult: Boolean val hasNetResult: Boolean
get() { get() {
return this.result?.netResult != null return this.result?.onlineNet != null
} }
// Manageable // Manageable
@ -788,7 +788,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT
SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT
SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT SessionRow.NET_RESULT -> this.result?.onlineNet?.toCurrency(currency) ?: NULL_TEXT
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT
SessionRow.GAME -> getFormattedGame() SessionRow.GAME -> getFormattedGame()
@ -903,7 +903,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
) )
SessionRow.NET_RESULT -> row.editingDescriptors( SessionRow.NET_RESULT -> row.editingDescriptors(
mapOf( mapOf(
"defaultValue" to result?.netResult "defaultValue" to result?.onlineNet
) )
) )
SessionRow.COMMENT -> row.editingDescriptors( SessionRow.COMMENT -> row.editingDescriptors(
@ -998,7 +998,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
} }
SessionRow.NET_RESULT -> { SessionRow.NET_RESULT -> {
this.result?.let { result -> this.result?.let { result ->
result.netResult = value as Double? result.onlineNet = value as Double?
} }
} }
SessionRow.COMMENT -> comment = value as String? ?: "" SessionRow.COMMENT -> comment = value as String? ?: ""

@ -253,7 +253,7 @@ class SessionCSVDescriptor(source: DataSource, private var isTournament: Boolean
session.bankroll = bankroll session.bankroll = bankroll
netResult?.let { netResult?.let {
session.result?.netResult = it // need to be set after BR session.result?.onlineNet = it // need to be set after BR
} }
session.result?.buyin?.let { session.result?.buyin?.let {

Loading…
Cancel
Save