|
|
|
|
@ -88,7 +88,6 @@ sealed class Criteria { |
|
|
|
|
abstract class RealmCriteria : Criteria() { |
|
|
|
|
inline fun <reified T: NameManageable> comparison(): List<Query> { |
|
|
|
|
return compare<QueryCondition.QueryDataCondition<NameManageable>, T>() |
|
|
|
|
// .sorted() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -111,7 +110,7 @@ sealed class Criteria { |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
}.distinct() |
|
|
|
|
return compareList<T, S>(values = values)//.sorted() |
|
|
|
|
return compareList<T, S>(values = values) |
|
|
|
|
} |
|
|
|
|
return listOf() |
|
|
|
|
} |
|
|
|
|
@ -200,13 +199,13 @@ sealed class Criteria { |
|
|
|
|
realm.where<Session>().sort("year", Sort.ASCENDING).findFirst()?.year?.let { |
|
|
|
|
for (index in 0..(yearNow - it)) { |
|
|
|
|
val yearCondition = QueryCondition.AnyYear().apply { |
|
|
|
|
listOfValues = arrayListOf(yearNow - index) |
|
|
|
|
listOfValues = arrayListOf(it + index) |
|
|
|
|
} |
|
|
|
|
years.add(Query(yearCondition)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
realm.close() |
|
|
|
|
years//.sorted() |
|
|
|
|
years |
|
|
|
|
} |
|
|
|
|
is Blinds -> comparison<QueryCondition.AnyBlind, String >() |
|
|
|
|
else -> throw PokerAnalyticsException.QueryTypeUnhandled |
|
|
|
|
@ -215,28 +214,29 @@ sealed class Criteria { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
inline fun <reified S : QueryCondition.QueryDataCondition<NameManageable >, reified T : NameManageable> compare(): List<Query> { |
|
|
|
|
val objects = mutableListOf<Query>() |
|
|
|
|
val objects = mutableListOf<S>() |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
realm.where<T>().findAll().forEach { |
|
|
|
|
val condition = (QueryCondition.getInstance<T>() as S).apply { |
|
|
|
|
setObject(it) |
|
|
|
|
} |
|
|
|
|
val query = Query(condition) |
|
|
|
|
objects.add(query) |
|
|
|
|
objects.add(condition) |
|
|
|
|
} |
|
|
|
|
objects.sorted() |
|
|
|
|
realm.close() |
|
|
|
|
return objects |
|
|
|
|
return objects.map { Query(it) } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun < reified S : QueryCondition.ListOfValues<T>, T:Any > compareList(values:List<T>): List<Query> { |
|
|
|
|
val objects = mutableListOf<Query>() |
|
|
|
|
val objects = mutableListOf<S>() |
|
|
|
|
values.forEach { |
|
|
|
|
val condition =(S::class.java.newInstance()).apply { |
|
|
|
|
listOfValues = arrayListOf(it) |
|
|
|
|
} |
|
|
|
|
objects.add(Query(condition)) |
|
|
|
|
objects.add(condition) |
|
|
|
|
} |
|
|
|
|
return objects |
|
|
|
|
objects.sorted() |
|
|
|
|
return objects.map { Query(it) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|