|
|
|
@ -7,14 +7,11 @@ import io.realm.Realm |
|
|
|
import io.realm.RealmConfiguration |
|
|
|
import io.realm.RealmConfiguration |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.kotlin.where |
|
|
|
import io.realm.kotlin.where |
|
|
|
import net.pokeranalytics.android.model.Limit |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.realm.Game |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.FakeDataManager |
|
|
|
import net.pokeranalytics.android.util.PokerAnalyticsLogs |
|
|
|
import net.pokeranalytics.android.util.PokerAnalyticsLogs |
|
|
|
import timber.log.Timber |
|
|
|
import timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PokerAnalyticsApplication : Application() { |
|
|
|
class PokerAnalyticsApplication : Application() { |
|
|
|
@ -68,8 +65,23 @@ class PokerAnalyticsApplication : Application() { |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
this.createFakeSessions() // debug |
|
|
|
this.createFakeSessions() // debug |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create fake sessions if we have less than 10 sessions |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun createFakeSessions() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
val sessionsCount = realm.where<Session>().findAll().size |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sessionsCount < 10) { |
|
|
|
|
|
|
|
FakeDataManager.createFakeSessions(2000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// |
|
|
|
// private fun createFakeStats() { |
|
|
|
// private fun createFakeStats() { |
|
|
|
// |
|
|
|
// |
|
|
|
@ -129,88 +141,4 @@ class PokerAnalyticsApplication : Application() { |
|
|
|
// |
|
|
|
// |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
private fun createFakeSessions() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val buyinList = arrayListOf(100.0, 200.0, 300.0, 500.0, 1000.0, 2000.0) |
|
|
|
|
|
|
|
val resultsList = arrayListOf( |
|
|
|
|
|
|
|
-2500.0, -2000.0, -1500.0, -1000.0, -500.0, 200.0, 1000.0, 1500.0, 2500.0 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val commitFrequency = 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
val games = realm.where<Game>().findAll() |
|
|
|
|
|
|
|
val bankroll = realm.where<Bankroll>().findAll().firstOrNull() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test endedSessions |
|
|
|
|
|
|
|
val sessions = realm.where<Session>().findAll() |
|
|
|
|
|
|
|
if (sessions.size < 10) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val numberOfSessions = 2000 |
|
|
|
|
|
|
|
Timber.d("*** Start creating ${numberOfSessions} fake computables...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val s = Date() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (index in 0..numberOfSessions) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index % commitFrequency == 0) { |
|
|
|
|
|
|
|
Timber.d("****** committing at ${index} computables...") |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val session = Session.newInstance(realm, false, bankroll) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
|
|
|
calendar.set( |
|
|
|
|
|
|
|
(2016..2018).random(), |
|
|
|
|
|
|
|
(0..11).random(), |
|
|
|
|
|
|
|
(0..28).random(), |
|
|
|
|
|
|
|
(0..23).random(), |
|
|
|
|
|
|
|
(0..59).random() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val startDate = calendar.time |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, (2..12).random()) |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, (0..59).random()) |
|
|
|
|
|
|
|
val endDate = calendar.time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session.startDate = startDate |
|
|
|
|
|
|
|
session.endDate = endDate |
|
|
|
|
|
|
|
session.creationDate = startDate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session.limit = Limit.values().random().ordinal |
|
|
|
|
|
|
|
session.game = games.random() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session.result?.let { result -> |
|
|
|
|
|
|
|
result.buyin = buyinList.random() |
|
|
|
|
|
|
|
result.netResult = resultsList.random() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val e = Date() |
|
|
|
|
|
|
|
val duration = (e.time - s.time) / 1000.0 |
|
|
|
|
|
|
|
Timber.d("*** ended in ${duration} seconds") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
Timber.e(e) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}.start() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |