Fixes import issues

blinds
Laurent 3 years ago
parent 6783e4a26f
commit d095a8c5af
  1. 3
      app/src/main/java/net/pokeranalytics/android/util/csv/CSVImporter.kt
  2. 27
      app/src/main/java/net/pokeranalytics/android/util/csv/PACSVDescriptor.kt
  3. 34
      app/src/main/java/net/pokeranalytics/android/util/csv/ProductCSVDescriptors.kt
  4. 10
      app/src/main/java/net/pokeranalytics/android/util/csv/SessionField.kt

@ -3,6 +3,8 @@ package net.pokeranalytics.android.util.csv
import android.os.Handler
import android.os.Looper
import io.realm.Realm
import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.util.extensions.count
import org.apache.commons.csv.CSVFormat
import org.apache.commons.csv.CSVParser
import org.apache.commons.csv.CSVRecord
@ -112,6 +114,7 @@ open class CSVImporter(istream: InputStream) {
if (this.currentDescriptor == null) { // find descriptor
this.currentDescriptor = this.findDescriptor(record)
this.currentDescriptor?.hasMatched(realm, record)
if (this.currentDescriptor == null) {

@ -8,6 +8,7 @@ import net.pokeranalytics.android.model.TableSize
import net.pokeranalytics.android.model.TournamentType
import net.pokeranalytics.android.model.realm.*
import net.pokeranalytics.android.model.utils.DataUtils
import net.pokeranalytics.android.util.extensions.count
import net.pokeranalytics.android.util.extensions.getOrCreate
import net.pokeranalytics.android.util.extensions.setHourMinutes
import org.apache.commons.csv.CSVRecord
@ -22,6 +23,14 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource,
vararg elements: CSVField)
: DataCSVDescriptor<T>(source, *elements) {
var noSessionImport: Boolean = false
init {
val realm = Realm.getDefaultInstance()
this.noSessionImport = realm.count(Session::class.java) == 0L
realm.close()
}
private var sameDaySessionCount: Int = 0
private var currentDay: String = ""
private var startInSeconds: Double = 20 * 3600.0
@ -177,6 +186,22 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource,
session.cgBigBlind = bb
} else {}
}
is SessionField.Blinds -> {
val blinds = value.split("/")
when (blinds.size) {
0 -> {}
1 -> {
session.cgBigBlind = field.parse(blinds.first())
}
else -> {
session.cgSmallBlind = field.parse(blinds[blinds.size - 2])
session.cgBigBlind = field.parse(blinds.last())
}
}
}
is SessionField.Ante -> {
// unmanaged atm
}
is SessionField.TableSize -> session.tableSize = TableSize.valueForLabel(value)
is SessionField.TournamentPosition -> session.result?.tournamentFinalPosition =
field.parse(value)
@ -242,7 +267,7 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource,
if (startDate != null && endDate != null && net != null) { // valid session
// session already in realm, we'd love not put it in Realm before doing the check
val count = DataUtils.sessionCount(realm, startDate!!, endDate!!, net)
if (count == 0) {
if (this.noSessionImport || count == 0) {
val managedSession = realm.copyToRealm(session)
managedSession.startDate = startDate

@ -17,6 +17,7 @@ class ProductCSVDescriptors {
runGoodCashGames,
runGoodTournaments,
pokerAnalyticsiOS,
pokerAnalytics6iOS,
pokerAnalyticsAndroid,
pokerAnalyticsAndroidTransactions
)
@ -190,6 +191,39 @@ class ProductCSVDescriptors {
)
}
private val pokerAnalytics6iOS: SessionCSVDescriptor
get() {
return SessionCSVDescriptor(
DataSource.POKER_ANALYTICS,
true,
SessionField.Start("Start Date", dateFormat = "MM/dd/yy HH:mm:ss"),
SessionField.End("End Date", dateFormat = "MM/dd/yy HH:mm:ss"),
SessionField.Break("Break", Calendar.SECOND),
SessionField.SessionType("Type"),
SessionField.Live("Live"),
SessionField.NumberOfTables("Tables"),
SessionField.Buyin("Buyin"),
SessionField.CashedOut("Cashed Out"),
SessionField.NetResult("Online Net"),
SessionField.Tips("Tips"),
SessionField.LimitType("Limit"),
SessionField.Game("Game"),
SessionField.TableSize("Table Size"),
SessionField.Location("Location"),
SessionField.Bankroll("Bankroll"),
SessionField.CurrencyCode("Currency Code"),
SessionField.CurrencyRate("Currency Rate"),
SessionField.Blinds("Blinds"),
SessionField.Ante("Ante"),
SessionField.TournamentTypeName("Tournament Type"),
SessionField.TournamentEntryFee("Entry fee"),
SessionField.TournamentNumberOfPlayers("Number of players"),
SessionField.TournamentPrizePool("Prize Pool"),
SessionField.TournamentPosition("Position"),
SessionField.Comment("Comment")
)
}
val pokerAnalyticsAndroidTransactions: TransactionCSVDescriptor
get() {
return TransactionCSVDescriptor(

@ -192,6 +192,16 @@ sealed class SessionField {
override var callback: ((String) -> Double?)? = null
) : NumberCSVField
data class Blinds(
override var header: String,
override var callback: ((String) -> Double?)? = null
) : NumberCSVField
data class Ante(
override var header: String,
override var callback: ((String) -> Double?)? = null
) : NumberCSVField
data class TournamentPosition(
override var header: String,
override var callback: ((String) -> Int?)? = null

Loading…
Cancel
Save