Skip to content

Commit

Permalink
Fix icpc csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Oct 16, 2023
1 parent ff8329f commit f836d4f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ object IcpcCsvExporter {
val rows = info.teams.keys.associateWith { scoreboardCalculator.getScoreboardRow(info, runsByTeam[it] ?: emptyList()) }
val ranking = scoreboardCalculator.getRanking(info, rows)
val ranks = ranking.order.zip(ranking.ranks).toMap()
val icpcTeamIds = info.teams.values.map { it.icpcId() to it.id }.sortedByDescending { ranks[it.second] }
val icpcTeamIds = info.teams.values.associate { it.id to it.icpcId() }

return buildString {
val printer = CSVPrinter(this, CSVFormat.DEFAULT.builder().setHeader(*fields.toTypedArray()).build())
for ((icpc_id, team_id) in icpcTeamIds) {
printer.printRecord(getFields(icpc_id, ranks[team_id]!!, rows[team_id]!!, ranking.awards.filter { team_id in it.teams }))
for (teamId in ranking.order.reversed()) {
printer.printRecord(getFields(icpcTeamIds[teamId]!!, ranks[teamId]!!, rows[teamId]!!, ranking.awards.filter { teamId in it.teams }))
}
}
}
Expand Down

0 comments on commit f836d4f

Please sign in to comment.