Skip to content

Commit

Permalink
Kinga/tm fixes (#4)
Browse files Browse the repository at this point in the history
* Update

* fix league

* Update TournamentManagerService.kt
  • Loading branch information
kinga-marszalkowska authored Mar 25, 2024
1 parent fc9e788 commit 8b60f8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/main/kotlin/odyseja/odysejapka/drive/ZspSheetsAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Team>) {
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()
}
Expand Down

0 comments on commit 8b60f8a

Please sign in to comment.