|
|
|
@ -40,10 +40,22 @@ enum class LiveData : Localizable { |
|
|
|
fun setUseCount(realm: Realm, realmResults: RealmResults<*>) { |
|
|
|
fun setUseCount(realm: Realm, realmResults: RealmResults<*>) { |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
realmResults.forEach { countableUsage -> |
|
|
|
realmResults.forEach { countableUsage -> |
|
|
|
(countableUsage as CountableUsage).useCount = it.where<Session>().equalTo( |
|
|
|
|
|
|
|
"${relatedEntity.simpleName.decapitalize()}.id", |
|
|
|
when (this) { |
|
|
|
countableUsage.uniqueIdentifier() |
|
|
|
TOURNAMENT_FEATURE -> { |
|
|
|
).count().toInt() |
|
|
|
(countableUsage as CountableUsage).useCount = it.where<Session>().contains( |
|
|
|
|
|
|
|
"tournamentFeatures.id", |
|
|
|
|
|
|
|
countableUsage.uniqueIdentifier() |
|
|
|
|
|
|
|
).count().toInt() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
(countableUsage as CountableUsage).useCount = it.where<Session>().equalTo( |
|
|
|
|
|
|
|
"${relatedEntity.simpleName.decapitalize()}.id", |
|
|
|
|
|
|
|
countableUsage.uniqueIdentifier() |
|
|
|
|
|
|
|
).count().toInt() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|