diff --git a/src/main/kotlin/odyseja/odysejapka/drive/ZspSheetsAdapter.kt b/src/main/kotlin/odyseja/odysejapka/drive/ZspSheetsAdapter.kt index 3e8cf89..b789024 100644 --- a/src/main/kotlin/odyseja/odysejapka/drive/ZspSheetsAdapter.kt +++ b/src/main/kotlin/odyseja/odysejapka/drive/ZspSheetsAdapter.kt @@ -73,7 +73,6 @@ class ZspSheetsAdapter( if (row.size == 0 || !isTime(row[0].toString())) { continue } - if (isJuniorTeam(code=row[2].toString())) continue teams.add( Team( performanceHour = row[0].toString(), @@ -104,10 +103,6 @@ class ZspSheetsAdapter( return judge.contains("SĘDZIOWIE") } - private fun isJuniorTeam(code: String): Boolean{ - return code.substring(1,2) == "0" && code.substring(3,4) == "0" - } - private fun isTime(cell: String): Boolean { val regex = "^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]\$".toRegex() return regex.matches(cell) diff --git a/src/main/kotlin/odyseja/odysejapka/tournamentManager/TournamentManagerService.kt b/src/main/kotlin/odyseja/odysejapka/tournamentManager/TournamentManagerService.kt index e0e7156..8aa2a5d 100644 --- a/src/main/kotlin/odyseja/odysejapka/tournamentManager/TournamentManagerService.kt +++ b/src/main/kotlin/odyseja/odysejapka/tournamentManager/TournamentManagerService.kt @@ -13,17 +13,30 @@ import java.nio.charset.Charset @Service class TournamentManagerService { + private fun isJuniorTeam(code: String): Boolean{ + return code.substring(1,2) == "J" && code.substring(3,4) == "J" + } + fun OutputStream.writeCsv(teams: List) { val writer = bufferedWriter() writer.write("""Problem,Division,Number,Name,City,Raw_longt1,Raw_longt2,Raw_style,Raw_spont,Penalty""") writer.newLine() teams.forEach { - if (it.code.substring(1,2) == "4") - writer.write("${it.code.substring(1,2)},${it.code.substring(3,4)},${it.membershipNumber},${it.shortTeamName},${it.city},${it.weightHeld},${it.longTermScore},${it.styleScore},${it.spontaneousScore},${it.penaltyScore}") - else - writer.write("${it.code.substring(1,2)},${it.code.substring(3,4)},${it.membershipNumber},${it.shortTeamName},${it.city},${it.longTermScore},,${it.styleScore},${it.spontaneousScore},${it.penaltyScore}") + // Junior teams and guest teams from other countries should not be imported + if (!isJuniorTeam(code=it.code) && it.membershipNumber != ""){ + var problemLeague = "" + if (it.league != "0") problemLeague = "${it.code.substring(3,4)}${it.league}" + else problemLeague = it.code.substring(3,4) + + if (it.code.substring(1,2) == "4") + writer.write("${it.code.substring(1,2)},${problemLeague},${it.membershipNumber},${it.shortTeamName},${it.city},${it.weightHeld},${it.longTermScore},${it.styleScore},${it.spontaneousScore},${it.penaltyScore}") + else + writer.write("${it.code.substring(1,2)},${problemLeague},${it.membershipNumber},${it.shortTeamName},${it.city},${it.longTermScore},,${it.styleScore},${it.spontaneousScore},${it.penaltyScore}") + + writer.newLine() + + } - writer.newLine() } writer.flush() }