|
|
|
@ -96,7 +96,7 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
distincts.mapNotNull { |
|
|
|
distincts.mapNotNull { |
|
|
|
it.numericValue |
|
|
|
it.numericValue |
|
|
|
}.distinct().forEach {value -> |
|
|
|
}.distinct().forEach {value -> |
|
|
|
val condition: QueryCondition.CustomFieldNumberQuery = when (this.customFieldType) { |
|
|
|
val condition: QueryCondition.CustomFieldNumberQuery = when (this.customFieldType(realm)) { |
|
|
|
CustomField.Type.AMOUNT.uniqueIdentifier -> QueryCondition.CustomFieldNumberQuery() |
|
|
|
CustomField.Type.AMOUNT.uniqueIdentifier -> QueryCondition.CustomFieldNumberQuery() |
|
|
|
CustomField.Type.NUMBER.uniqueIdentifier -> QueryCondition.CustomFieldAmountQuery() |
|
|
|
CustomField.Type.NUMBER.uniqueIdentifier -> QueryCondition.CustomFieldAmountQuery() |
|
|
|
else -> throw PokerAnalyticsException.QueryValueMapUnexpectedValue |
|
|
|
else -> throw PokerAnalyticsException.QueryValueMapUnexpectedValue |
|
|
|
@ -165,15 +165,8 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
object TournamentFees : ListCriteria(18) |
|
|
|
object TournamentFees : ListCriteria(18) |
|
|
|
object Cash : SimpleCriteria(listOf(QueryCondition.IsCash), 19) |
|
|
|
object Cash : SimpleCriteria(listOf(QueryCondition.IsCash), 19) |
|
|
|
object Tournament : SimpleCriteria(listOf(QueryCondition.IsTournament), 20) |
|
|
|
object Tournament : SimpleCriteria(listOf(QueryCondition.IsTournament), 20) |
|
|
|
data class ListCustomFields(var customField: CustomField) : RealmCriteria(21), CustomFieldCriteria { |
|
|
|
data class ListCustomFields(override var customFieldId: String) : RealmCriteria(21), CustomFieldCriteria |
|
|
|
override var customFieldId: String = customField.id |
|
|
|
data class ValueCustomFields(override var customFieldId: String) : ListCriteria(22), CustomFieldCriteria |
|
|
|
override var customFieldType: Int = customField.type |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data class ValueCustomFields(var customField: CustomField) : ListCriteria(22), CustomFieldCriteria { |
|
|
|
|
|
|
|
override var customFieldId: String = customField.id |
|
|
|
|
|
|
|
override var customFieldType: Int = customField.type |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val queries: List<Query> |
|
|
|
val queries: List<Query> |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
@ -249,11 +242,14 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
is Blinds -> comparison<QueryCondition.AnyBlind, String>() |
|
|
|
is Blinds -> comparison<QueryCondition.AnyBlind, String>() |
|
|
|
is ListCustomFields -> comparison<CustomFieldEntry>() |
|
|
|
is ListCustomFields -> comparison<CustomFieldEntry>() |
|
|
|
is ValueCustomFields -> { |
|
|
|
is ValueCustomFields -> { |
|
|
|
when (customFieldType) { |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
val queries = when (this.customFieldType(realm)) { |
|
|
|
CustomField.Type.AMOUNT.uniqueIdentifier -> comparison<QueryCondition.CustomFieldAmountQuery, Double >() |
|
|
|
CustomField.Type.AMOUNT.uniqueIdentifier -> comparison<QueryCondition.CustomFieldAmountQuery, Double >() |
|
|
|
CustomField.Type.NUMBER.uniqueIdentifier -> comparison<QueryCondition.CustomFieldNumberQuery, Double >() |
|
|
|
CustomField.Type.NUMBER.uniqueIdentifier -> comparison<QueryCondition.CustomFieldNumberQuery, Double >() |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
queries |
|
|
|
} |
|
|
|
} |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
} |
|
|
|
} |
|
|
|
@ -279,8 +275,8 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
AllMonthsUpToNow -> R.string.month |
|
|
|
AllMonthsUpToNow -> R.string.month |
|
|
|
Blinds -> R.string.blind |
|
|
|
Blinds -> R.string.blind |
|
|
|
TournamentFees -> R.string.entry_fees |
|
|
|
TournamentFees -> R.string.entry_fees |
|
|
|
is ListCustomFields -> this.customField.resId |
|
|
|
// is ListCustomFields -> this.customField.resId |
|
|
|
is ValueCustomFields -> this.customField.resId |
|
|
|
// is ValueCustomFields -> this.customField.resId |
|
|
|
else -> null |
|
|
|
else -> null |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -313,6 +309,11 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
return objects.map { Query(it) } |
|
|
|
return objects.map { Query(it) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SavableEnum |
|
|
|
|
|
|
|
override fun valuesInternal(): Array<Criteria> { |
|
|
|
|
|
|
|
return all.toTypedArray() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val all: List<Criteria> |
|
|
|
val all: List<Criteria> |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return listOf( |
|
|
|
return listOf( |
|
|
|
@ -323,17 +324,19 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row |
|
|
|
AllMonthsUpToNow, Blinds, TournamentFees |
|
|
|
AllMonthsUpToNow, Blinds, TournamentFees |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SavableEnum |
|
|
|
|
|
|
|
override fun valuesInternal(): Array<Criteria> { |
|
|
|
|
|
|
|
return all.toTypedArray() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CustomFieldCriteria { |
|
|
|
interface CustomFieldCriteria { |
|
|
|
var customFieldId: String |
|
|
|
var customFieldId: String |
|
|
|
var customFieldType: Int |
|
|
|
|
|
|
|
|
|
|
|
fun customField(realm: Realm) : CustomField { |
|
|
|
|
|
|
|
return realm.findById(this.customFieldId) ?: throw IllegalStateException("Custom field not found") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun customFieldType(realm: Realm): Int { |
|
|
|
|
|
|
|
return this.customField(realm).type |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |