|
|
|
|
@ -37,7 +37,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
private var stringTournament = "" |
|
|
|
|
|
|
|
|
|
private lateinit var statsAdapter: RowRepresentableAdapter |
|
|
|
|
private var computedResults : List<ComputedResults>? = null |
|
|
|
|
private var report : Report? = null |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
@ -137,31 +137,31 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
|
|
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
|
|
|
|
|
|
var results = listOf<ComputedResults>() |
|
|
|
|
var r = Report() |
|
|
|
|
val test = GlobalScope.async { |
|
|
|
|
val s = Date() |
|
|
|
|
Timber.d(">>> start...") |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
results = createSessionGroupsAndStartCompute(realm) |
|
|
|
|
computedResults = results |
|
|
|
|
r = createSessionGroupsAndStartCompute(realm) |
|
|
|
|
report = r |
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
val e = Date() |
|
|
|
|
val duration = (e.time - s.time) / 1000.0 |
|
|
|
|
Timber.d(">>> ended in ${duration} seconds") |
|
|
|
|
Timber.d(">>> ended in $duration seconds") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
test.await() |
|
|
|
|
|
|
|
|
|
if (!isDetached) { |
|
|
|
|
showResults(results) |
|
|
|
|
showResults(r) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun createSessionGroupsAndStartCompute(realm: Realm) : List<ComputedResults> { |
|
|
|
|
private fun createSessionGroupsAndStartCompute(realm: Realm) : Report { |
|
|
|
|
|
|
|
|
|
val allStats: List<Stat> = listOf(Stat.NETRESULT, Stat.HOURLY_RATE, Stat.AVERAGE, Stat.NUMBER_OF_SETS, Stat.AVERAGE_DURATION, Stat.DURATION) |
|
|
|
|
val allSessionGroup = ComputableGroup(stringAll, listOf(), allStats) |
|
|
|
|
@ -176,16 +176,16 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun showResults(results: List<ComputedResults>) { |
|
|
|
|
this.rowRepresentables = this.convertResultsIntoRepresentables(results) |
|
|
|
|
private fun showResults(report: Report) { |
|
|
|
|
this.rowRepresentables = this.convertReportIntoRepresentables(report) |
|
|
|
|
statsAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun convertResultsIntoRepresentables(results: List<ComputedResults>) : ArrayList<RowRepresentable> { |
|
|
|
|
private fun convertReportIntoRepresentables(report: Report) : ArrayList<RowRepresentable> { |
|
|
|
|
|
|
|
|
|
val rows: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
|
|
|
|
|
|
results.forEach { result -> |
|
|
|
|
report.results.forEach { result -> |
|
|
|
|
rows.add(CustomizableRowRepresentable(title = result.group.name)) |
|
|
|
|
result.group.stats?.forEach { stat -> |
|
|
|
|
rows.add(StatRepresentable(stat, result.computedStat(stat), result.group.name)) |
|
|
|
|
@ -202,7 +202,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
if (row is StatRepresentable) { |
|
|
|
|
|
|
|
|
|
// filter groups |
|
|
|
|
val groupResults = this.computedResults?.filter { |
|
|
|
|
val groupResults = this.report?.results?.filter { |
|
|
|
|
it.group.name == row.groupName |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -217,7 +217,7 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
|
|
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
|
|
|
|
|
|
var results = listOf<ComputedResults>() |
|
|
|
|
var report = Report() |
|
|
|
|
val test = GlobalScope.async { |
|
|
|
|
val s = Date() |
|
|
|
|
Timber.d(">>> start...") |
|
|
|
|
@ -225,18 +225,18 @@ class StatsFragment : SessionObserverFragment(), StaticRowRepresentableDataSourc |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
val options = Calculator.Options() |
|
|
|
|
options.evolutionValues = Calculator.Options.EvolutionValues.STANDARD |
|
|
|
|
results = Calculator.computeGroups(realm, listOf(computableGroup), options) |
|
|
|
|
report = Calculator.computeGroups(realm, listOf(computableGroup), options) |
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
val e = Date() |
|
|
|
|
val duration = (e.time - s.time) / 1000.0 |
|
|
|
|
Timber.d(">>> ended in ${duration} seconds") |
|
|
|
|
Timber.d(">>> ended in $duration seconds") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
test.await() |
|
|
|
|
|
|
|
|
|
if (!isDetached) { |
|
|
|
|
results.firstOrNull()?.defaultStatEntries(stat)?.let { entries -> |
|
|
|
|
report.results.firstOrNull()?.defaultStatEntries(stat)?.let { entries -> |
|
|
|
|
GraphActivity.newInstance(requireContext(), stat, entries) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|