|
|
|
@ -4,7 +4,6 @@ import io.realm.RealmQuery |
|
|
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
import net.pokeranalytics.android.model.realm.FilterCondition |
|
|
|
import net.pokeranalytics.android.model.realm.FilterCondition |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.extensions.endOfDay |
|
|
|
import net.pokeranalytics.android.util.extensions.endOfDay |
|
|
|
import net.pokeranalytics.android.util.extensions.startOfDay |
|
|
|
import net.pokeranalytics.android.util.extensions.startOfDay |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
@ -30,7 +29,7 @@ enum class QueryCondition(var operator: Operator? = null) { |
|
|
|
LIMIT, |
|
|
|
LIMIT, |
|
|
|
TABLE_SIZE, |
|
|
|
TABLE_SIZE, |
|
|
|
TOURNAMENT_TYPE, |
|
|
|
TOURNAMENT_TYPE, |
|
|
|
STAKE, |
|
|
|
BLIND, |
|
|
|
LAST_GAMES, |
|
|
|
LAST_GAMES, |
|
|
|
LAST_SESSIONS, |
|
|
|
LAST_SESSIONS, |
|
|
|
MORE_NUMBER_OF_TABLE(Operator.MORE), |
|
|
|
MORE_NUMBER_OF_TABLE(Operator.MORE), |
|
|
|
@ -112,7 +111,7 @@ enum class QueryCondition(var operator: Operator? = null) { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
BANKROLL, GAME, LOCATION, ANY_TOURNAMENT_FEATURES, ALL_TOURNAMENT_FEATURES, TOURNAMENT_NAME -> arrayOf("ids") |
|
|
|
BANKROLL, GAME, LOCATION, ANY_TOURNAMENT_FEATURES, ALL_TOURNAMENT_FEATURES, TOURNAMENT_NAME -> arrayOf("ids") |
|
|
|
LIMIT, TOURNAMENT_TYPE, TABLE_SIZE -> arrayOf("values") |
|
|
|
LIMIT, TOURNAMENT_TYPE, TABLE_SIZE -> arrayOf("values") |
|
|
|
STAKE -> arrayOf("stakes", "hasDefaultCurrency") |
|
|
|
BLIND -> arrayOf("blinds", "hasDefaultCurrency") |
|
|
|
STARTED_FROM_DATE, STARTED_TO_DATE, ENDED_FROM_DATE, ENDED_TO_DATE -> arrayOf("date") |
|
|
|
STARTED_FROM_DATE, STARTED_TO_DATE, ENDED_FROM_DATE, ENDED_TO_DATE -> arrayOf("date") |
|
|
|
DAY_OF_WEEK -> arrayOf("dayOfWeek") |
|
|
|
DAY_OF_WEEK -> arrayOf("dayOfWeek") |
|
|
|
MONTH -> arrayOf("month") |
|
|
|
MONTH -> arrayOf("month") |
|
|
|
@ -159,11 +158,11 @@ enum class QueryCondition(var operator: Operator? = null) { |
|
|
|
val ids: Array<String> by valueMap |
|
|
|
val ids: Array<String> by valueMap |
|
|
|
realmQuery.`in`(fieldName, ids) |
|
|
|
realmQuery.`in`(fieldName, ids) |
|
|
|
} |
|
|
|
} |
|
|
|
STAKE -> { |
|
|
|
BLIND -> { |
|
|
|
val stakes: Array<String> by valueMap |
|
|
|
val blinds: Array<String> by valueMap |
|
|
|
val hasDefaultCurrency: Array<Boolean> by valueMap |
|
|
|
val hasDefaultCurrency: Array<Boolean> by valueMap |
|
|
|
//realmQuery.`in`(fieldName, stakes) |
|
|
|
//realmQuery.`in`(fieldName, blinds) |
|
|
|
stakes.forEachIndexed { index, s -> |
|
|
|
blinds.forEachIndexed { index, s -> |
|
|
|
val isUsingDefaultCurrency = hasDefaultCurrency[index] |
|
|
|
val isUsingDefaultCurrency = hasDefaultCurrency[index] |
|
|
|
realmQuery.beginGroup() |
|
|
|
realmQuery.beginGroup() |
|
|
|
if (isUsingDefaultCurrency) { |
|
|
|
if (isUsingDefaultCurrency) { |
|
|
|
@ -174,7 +173,7 @@ enum class QueryCondition(var operator: Operator? = null) { |
|
|
|
realmQuery.equalTo(fieldName, s) |
|
|
|
realmQuery.equalTo(fieldName, s) |
|
|
|
} |
|
|
|
} |
|
|
|
.endGroup() |
|
|
|
.endGroup() |
|
|
|
if (index < stakes.size - 1) { |
|
|
|
if (index < blinds.size - 1) { |
|
|
|
realmQuery.or() |
|
|
|
realmQuery.or() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -284,9 +283,9 @@ enum class QueryCondition(var operator: Operator? = null) { |
|
|
|
LIMIT, TOURNAMENT_TYPE, TABLE_SIZE -> { |
|
|
|
LIMIT, TOURNAMENT_TYPE, TABLE_SIZE -> { |
|
|
|
valueMap = mapOf("values" to filterCondition.values) |
|
|
|
valueMap = mapOf("values" to filterCondition.values) |
|
|
|
} |
|
|
|
} |
|
|
|
STAKE -> { |
|
|
|
BLIND -> { |
|
|
|
valueMap = mapOf( |
|
|
|
valueMap = mapOf( |
|
|
|
"stakes" to filterCondition.stakes, |
|
|
|
"blinds" to filterCondition.blinds, |
|
|
|
"hasDefaultCurrency" to filterCondition.hasDefaultCurrency) |
|
|
|
"hasDefaultCurrency" to filterCondition.hasDefaultCurrency) |
|
|
|
} |
|
|
|
} |
|
|
|
STARTED_FROM_DATE, STARTED_TO_DATE, ENDED_FROM_DATE, ENDED_TO_DATE -> { |
|
|
|
STARTED_FROM_DATE, STARTED_TO_DATE, ENDED_FROM_DATE, ENDED_TO_DATE -> { |
|
|
|
|