-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/tournament component - knockout stage #919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SzBeni2003
wants to merge
106
commits into
staging
Choose a base branch
from
feature/tournament-component
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
106 commits
Select commit
Hold shift + click to select a range
2148479
tournament component - 1 attribute, working backend&frontend for it
SzBeni2003 afb7eda
tournament component - 2nd attribute
SzBeni2003 050e4d0
tournament: Component Settings fixed, some reformat, new attributes
SzBeni2003 c1e9a3a
tournament - knockout stage, registration - backend stuff
SzBeni2003 d3f32ad
tournament match - entity, repository done, controller done
SzBeni2003 c87d1fc
some test data; still figuring out the schema
SzBeni2003 908686f
still figuring out the schema
SzBeni2003 a801397
generate matches for knockoutstage
SzBeni2003 affbbb3
Api + frontend hook
SzBeni2003 727f7e1
when did I even touch this file?
SzBeni2003 e448ffe
rebase onto rebase
SzBeni2003 4f0aa85
tournament component - 2nd attribute
SzBeni2003 eab29dc
tournament: Component Settings fixed, some reformat, new attributes
SzBeni2003 340b1f4
tournament - knockout stage, registration - backend stuff
SzBeni2003 f1ba65d
tournament match - entity, repository done, controller done
SzBeni2003 11197f0
some test data; still figuring out the schema
SzBeni2003 53a3816
still figuring out the schema
SzBeni2003 2a7ae72
generate matches for knockoutstage
SzBeni2003 fd200f3
Api + frontend hook
SzBeni2003 452bc73
when did I even touch this file?
SzBeni2003 1a46dc5
knockout stage frontend, cannot compile...
SzBeni2003 bad9a6b
Merge remote-tracking branch 'origin/feature/tournament-component' in…
SzBeni2003 2de4135
api working, frontend for Detailed Tournament view (not tested yet)
SzBeni2003 a152ea8
Tournament Detailed View getting some clothes
SzBeni2003 6d883fd
removed some stuff so the backend runs
SzBeni2003 99d5e9b
frontend looks better
SzBeni2003 929ce86
Merge branch 'refs/heads/staging' into feature/tournament-component
SzBeni2003 8c1709e
bracket connectors
SzBeni2003 78e30bd
update component to support S3 buckets (and minor stuff)
SzBeni2003 3420275
small adjustments for Match.tsx
SzBeni2003 fc6f543
bulk deletion for matches and stages, working bracket generation
SzBeni2003 9402874
Merge branch 'staging' into feature/tournament-component
SzBeni2003 2de7f6d
registerTeam WIP
SzBeni2003 eaa3f12
registerTeam
SzBeni2003 d0f9826
Merge remote-tracking branch 'origin/staging' into feature/tournament…
SzBeni2003 60f9df9
inputType, overviewType
SzBeni2003 aa9fc4c
menu option available for tournaments
SzBeni2003 5375720
create knockoutstage without memorizing the tournamentId (PLS CHECK t…
SzBeni2003 2d8f848
WIP joining to tournaments
SzBeni2003 1f2e177
WIP joining to tournaments - backend support for user/group ownership…
SzBeni2003 c7f2c8f
tournaments - access control
SzBeni2003 4560314
tournaments - access control
SzBeni2003 ab5b340
dependency cycles removed
SzBeni2003 6cd66a5
frontend support for joining tournaments
SzBeni2003 2f61ea5
seeds (lots of stuff, wip)
SzBeni2003 8ce0f77
seedsetter admin page
SzBeni2003 e11b3ab
initial seed setting api (needs testing and some modifications)
SzBeni2003 ce526bb
initial seed setting api (needs testing and some modifications)
SzBeni2003 5f996fc
Merge remote-tracking branch 'origin/feature/tournament-component' in…
SzBeni2003 646e6b5
Merge branch 'staging' into feature/tournament-component
SzBeni2003 39a9660
seeds working, updating etc
SzBeni2003 97e15bb
reordered functions in stageservice
SzBeni2003 2d3e475
typo
SzBeni2003 93c2d85
matchAdmin
SzBeni2003 4211111
seedSettings now include byeGames as well
SzBeni2003 299db67
admin frontend (new+improvements)
SzBeni2003 1b1b4ae
fixed winner() for seed continuity
SzBeni2003 972864d
some small stuff
SzBeni2003 65e2aaf
thymeleaf my beloved
SzBeni2003 fa58f06
finalizeBtn fade if seeds modified
SzBeni2003 5dd4a91
finalizeBtn fade if seeds modified
SzBeni2003 4c2042d
seeds
SzBeni2003 a8ae65d
merge staging into feature/tournament-component (#917)
SzBeni2003 fb13535
syncing java and kotlin target jvm versions
SzBeni2003 b83d16d
react-router
SzBeni2003 9c79d1e
seedSettings complete: finalize seeds, finalized seedSettings page sp…
SzBeni2003 888b473
thymeleaf my beloved
SzBeni2003 7ba6438
thymeleaf my beloved
SzBeni2003 07fccb2
UNTESTED - match score input
SzBeni2003 0895e54
Merge branch 'staging' into feature/tournament-component
SzBeni2003 44faf19
changes requested pt1
SzBeni2003 1e96f86
changes requested pt2
SzBeni2003 44f05e8
changes requested pt3 - joinTournamentMutation
SzBeni2003 531db8d
configs
SzBeni2003 f0b3cce
configs
SzBeni2003 77f5cd4
changes requested - pt4
SzBeni2003 cc87f02
changes requested - pt5
SzBeni2003 b43827b
Merge remote-tracking branch 'origin/staging' into feature/tournament…
SzBeni2003 e00e69f
random deleted file got back with a merge
SzBeni2003 13562bd
sonar errors
SzBeni2003 70c9379
sonar codesmell
SzBeni2003 8914324
sonar codesmell
SzBeni2003 400480f
sonar codesmell
SzBeni2003 b753ef3
sonar codesmell
SzBeni2003 97c1c2e
unused imports, properties
SzBeni2003 4f109d3
unused imports, properties
SzBeni2003 d2377e0
sonar
SzBeni2003 2512650
refactor knockoutStage to tournamentStage - the base for adding Group…
SzBeni2003 d70ad91
fixed ambiguous mappings; create stage working with group stages as well
SzBeni2003 fda8702
create stage working with group stages as well
SzBeni2003 a2365f3
byeGames, match generation fixed
SzBeni2003 5411370
seed save fixed
SzBeni2003 e9a409e
seed save fixed
SzBeni2003 faeb4cc
Merge branch 'staging' into feature/tournament-component
SzBeni2003 091f2af
byeGame; react hooks
SzBeni2003 7fba9ae
stageResult comparator
SzBeni2003 7251d38
matchScore updating IN_PROGRESS Matches
SzBeni2003 9f24e68
reverted openness of create
SzBeni2003 06184dd
Merge branch 'staging' into feature/tournament-component
SzBeni2003 753e028
rewrote pages and components without chakra-ui
SzBeni2003 1d85c9c
updated enums and usages
SzBeni2003 c9afeb0
createMatches init
SzBeni2003 b1355b4
more data sent by API
SzBeni2003 74cddea
fixed errors
SzBeni2003 44f367d
join tournament and cancel tournament
SzBeni2003 8aa0532
improvements for joining tournaments
SzBeni2003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/MatchGroupDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import hu.bme.sch.cmsch.admin.GenerateOverview | ||
| import hu.bme.sch.cmsch.admin.OverviewType | ||
| import hu.bme.sch.cmsch.model.IdentifiableEntity | ||
|
|
||
| data class MatchGroupDto( | ||
|
|
||
| @property:GenerateOverview(renderer = OverviewType.ID, columnName = "ID", order = -1) | ||
| override var id: Int = 0, | ||
|
|
||
| @property:GenerateOverview(columnName = "Név", order = 1) | ||
| var name: String = "", | ||
|
|
||
| @property:GenerateOverview(columnName = "Helyszín", order = 2) | ||
| var location: String = "", | ||
|
|
||
| @property:GenerateOverview(columnName = "Közeli meccsek száma", order = 3) | ||
| var matchCount: Int = 0, | ||
|
|
||
| ): IdentifiableEntity |
12 changes: 12 additions & 0 deletions
12
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/ParticipantDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| data class ParticipantDto( | ||
| var teamId: Int = 0, | ||
| var teamName: String = "", | ||
| ) | ||
|
|
||
| data class SeededParticipantDto( | ||
| var teamId: Int = 0, | ||
| var teamName: String = "", | ||
| var seed: Int = 0, | ||
| ) |
24 changes: 24 additions & 0 deletions
24
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/StageGroupDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import hu.bme.sch.cmsch.admin.GenerateOverview | ||
| import hu.bme.sch.cmsch.admin.OverviewType | ||
| import hu.bme.sch.cmsch.model.IdentifiableEntity | ||
|
|
||
| data class StageGroupDto( | ||
|
|
||
| @property:GenerateOverview(renderer = OverviewType.ID, columnName = "ID", order = -1) | ||
| override var id: Int = 0, | ||
|
|
||
| @property:GenerateOverview(columnName = "Név", order = 1) | ||
| var name: String = "", | ||
|
|
||
| @property:GenerateOverview(columnName = "Helyszín", order = 2) | ||
| var location: String = "", | ||
|
|
||
| @property:GenerateOverview(columnName = "Résztvevők száma", order = 3) | ||
| var participantCount: Int = 0, | ||
|
|
||
| @property:GenerateOverview(columnName = "Szakaszok száma", order = 4) | ||
| var stageCount: Int = 0 | ||
|
|
||
| ): IdentifiableEntity |
48 changes: 48 additions & 0 deletions
48
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/StageResultDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude | ||
|
|
||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
| data class StageResultDto( | ||
| val teamId: Int, | ||
| val teamName: String, | ||
| val stageId: Int = 0, | ||
| var highlighted: Boolean = false, | ||
| var initialSeed: Int = 0, | ||
| var highestSeed: Int = 0, | ||
| var detailedStats: GroupStageResults? = null, | ||
| ): Comparable<StageResultDto> { | ||
| override fun compareTo(other: StageResultDto): Int { | ||
| if (this.stageId != other.stageId) { | ||
| return this.stageId.compareTo(other.stageId) | ||
| } | ||
| if (this.detailedStats == null && other.detailedStats == null) { | ||
| return -this.initialSeed.compareTo(other.highestSeed) | ||
| } | ||
| if (this.detailedStats == null) { | ||
| return -1 // null detailed stats are considered better (knockout stages are later) | ||
| } | ||
| return compareValuesBy(this, other, | ||
| { it.detailedStats?:GroupStageResults()}, {it.initialSeed}, {it.highlighted}) | ||
| } | ||
| } | ||
| data class GroupStageResults( | ||
| var group: String = "", | ||
| var position: UShort = UShort.MAX_VALUE, | ||
| var points: UInt = 0u, | ||
| var won: UShort = 0u, | ||
| var drawn: UShort = 0u, | ||
| var lost: UShort = 0u, | ||
| var goalsFor: UInt = 0u, | ||
| var goalsAgainst: UInt = 0u, | ||
| var goalDifference: Int = 0 | ||
| ): Comparable<GroupStageResults> { | ||
| override fun compareTo(other: GroupStageResults): Int { | ||
| return compareValuesBy(this, other, | ||
| { -it.position.toInt() }, | ||
| { it.points }, | ||
| { it.won }, | ||
| { it.goalDifference }, | ||
| { it.goalsFor }) | ||
| } | ||
| } | ||
66 changes: 66 additions & 0 deletions
66
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentApiController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import hu.bme.sch.cmsch.model.RoleType | ||
| import hu.bme.sch.cmsch.util.getUserOrNull | ||
| import hu.bme.sch.cmsch.util.isAvailableForRole | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnBean | ||
| import org.springframework.http.HttpStatus | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.security.core.Authentication | ||
| import org.springframework.web.bind.annotation.* | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api") | ||
| @ConditionalOnBean(TournamentComponent::class) | ||
| class TournamentApiController( | ||
| private val tournamentComponent: TournamentComponent, | ||
| private val tournamentService: TournamentService, | ||
| ) { | ||
|
|
||
| @GetMapping("/tournament") | ||
| fun listTournaments(auth: Authentication?): ResponseEntity<List<TournamentPreviewView>> { | ||
| val user = auth?.getUserOrNull() | ||
| if (!tournamentComponent.minRole.isAvailableForRole(user?.role ?: RoleType.GUEST)) | ||
| return ResponseEntity.status(HttpStatus.FORBIDDEN).body(listOf()) | ||
| if (!tournamentComponent.showTournamentsAtAll) { | ||
| return ResponseEntity.status(HttpStatus.BAD_REQUEST).build() | ||
| } | ||
|
|
||
| return ResponseEntity.ok(tournamentService.listAllTournaments()) | ||
| } | ||
|
|
||
|
|
||
| @GetMapping("/tournament/{tournamentId}") | ||
| fun tournamentDetails( | ||
| @PathVariable tournamentId: Int, | ||
| auth: Authentication? | ||
| ): ResponseEntity<OptionalTournamentView>{ | ||
| val user = auth?.getUserOrNull() | ||
| if (!tournamentComponent.minRole.isAvailableForRole(user?.role ?: RoleType.GUEST)) | ||
| return ResponseEntity.status(HttpStatus.FORBIDDEN).build() | ||
|
|
||
| return tournamentService.showTournament(tournamentId, user)?.let { ResponseEntity.ok(it) } | ||
| ?: ResponseEntity.status(HttpStatus.NOT_FOUND).build() | ||
| } | ||
|
|
||
| @PutMapping("/tournament/register") | ||
| fun registerTeam( | ||
| @RequestBody tournamentJoinDto: TournamentJoinDto, | ||
| auth: Authentication? | ||
| ): TournamentJoinStatus { | ||
| val user = auth?.getUserOrNull() | ||
| ?: return TournamentJoinStatus.INSUFFICIENT_PERMISSIONS | ||
| return tournamentService.register(tournamentJoinDto.id, user) | ||
| } | ||
|
|
||
| @PutMapping("/tournament/unregister") | ||
| fun unregisterTeam( | ||
| @RequestBody tournamentJoinDto: TournamentJoinDto, | ||
| auth: Authentication? | ||
| ): TournamentCancelStatus { | ||
| val user = auth?.getUserOrNull() | ||
| ?: return TournamentCancelStatus.INSUFFICIENT_PERMISSIONS | ||
| return tournamentService.unregister(tournamentJoinDto.id, user) | ||
| } | ||
|
|
||
| } |
10 changes: 10 additions & 0 deletions
10
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentCancelStatus.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| enum class TournamentCancelStatus { | ||
| OK, | ||
| NOT_PLAYING, | ||
| TOURNAMENT_NOT_FOUND, | ||
| NOT_CANCELABLE, | ||
| INSUFFICIENT_PERMISSIONS, | ||
| ERROR | ||
| } |
56 changes: 56 additions & 0 deletions
56
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentComponent.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import hu.bme.sch.cmsch.component.ComponentBase | ||
| import hu.bme.sch.cmsch.model.RoleType | ||
| import hu.bme.sch.cmsch.service.ControlPermissions | ||
| import hu.bme.sch.cmsch.setting.* | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
| import org.springframework.core.env.Environment | ||
| import org.springframework.stereotype.Service | ||
|
|
||
|
|
||
| @Service | ||
| @ConditionalOnProperty( | ||
| prefix = "hu.bme.sch.cmsch.component.load", | ||
| name = ["tournament"], | ||
| havingValue = "true", | ||
| matchIfMissing = false | ||
| ) | ||
| class TournamentComponent ( | ||
| componentSettingService: ComponentSettingService, | ||
| env: Environment | ||
| ) : ComponentBase( | ||
| componentSettingService, | ||
| "tournament", | ||
| "/tournament", | ||
| "Tournament", | ||
| ControlPermissions.PERMISSION_CONTROL_TOURNAMENT, | ||
| listOf(), | ||
| env | ||
| ) { | ||
|
|
||
| val tournamentGroup by SettingGroup(fieldName = "Versenyek") | ||
| final var title by StringSettingRef( | ||
| "Sportversenyek", | ||
| fieldName = "Lap címe", description = "Ez jelenik meg a böngésző címsorában" | ||
| ) | ||
| final override var menuDisplayName by StringSettingRef( | ||
| "Sportversenyek", serverSideOnly = true, | ||
| fieldName = "Menü neve", description = "Ez lesz a neve a menünek" | ||
| ) | ||
| final override var minRole by MinRoleSettingRef( | ||
| setOf(), fieldName = "Jogosultságok", | ||
| description = "Melyik roleokkal nyitható meg az oldal" | ||
| ) | ||
|
|
||
| var showTournamentsAtAll by BooleanSettingRef( | ||
| false, fieldName = "Leküldött", | ||
| description = "Ha igaz, akkor leküldésre kerülnek a versenyek" | ||
| ) | ||
|
|
||
| var closeMatchesTimeWindow by NumberSettingRef( | ||
| defaultValue = 120, fieldName = "Közelgő mérkőzések időablaka", | ||
| description = "Mennyi időn belül közelgő mérkőzések jelenjenek meg a match admin oldalon", | ||
| minRoleToEdit = RoleType.ADMIN | ||
| ) | ||
| } |
36 changes: 36 additions & 0 deletions
36
...nd/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentComponentController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import hu.bme.sch.cmsch.component.ComponentApiBase | ||
| import hu.bme.sch.cmsch.component.app.MenuService | ||
| import hu.bme.sch.cmsch.service.AdminMenuService | ||
| import hu.bme.sch.cmsch.service.AuditLogService | ||
| import hu.bme.sch.cmsch.service.ControlPermissions | ||
| import hu.bme.sch.cmsch.service.StorageService | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnBean | ||
| import org.springframework.stereotype.Controller | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
|
|
||
| @Controller | ||
| @RequestMapping("/admin/control/component/tournament") | ||
| @ConditionalOnBean(TournamentComponent::class) | ||
| class TournamentComponentController( | ||
| adminMenuService: AdminMenuService, | ||
| component: TournamentComponent, | ||
| private val menuService: MenuService, | ||
| private val tournamentService: TournamentService, | ||
| private val auditLogService: AuditLogService, | ||
| private val storageService: StorageService, | ||
| service: MenuService | ||
| ) : ComponentApiBase( | ||
| adminMenuService, | ||
| TournamentComponent::class.java, | ||
| component, | ||
| ControlPermissions.PERMISSION_CONTROL_TOURNAMENT, | ||
| "Tournament", | ||
| "Tournament beállítások", | ||
| auditLogService = auditLogService, | ||
| menuService = menuService, | ||
| storageService = storageService | ||
| ) { | ||
|
|
||
| } |
11 changes: 11 additions & 0 deletions
11
...in/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentComponentEntityConfiguration.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnBean | ||
| import org.springframework.boot.persistence.autoconfigure.EntityScan | ||
| import org.springframework.context.annotation.Configuration | ||
|
|
||
|
|
||
| @Configuration | ||
| @ConditionalOnBean(TournamentComponent::class) | ||
| @EntityScan(basePackageClasses = [TournamentComponent::class]) | ||
| class TournamentComponentEntityConfiguration |
66 changes: 66 additions & 0 deletions
66
backend/src/main/kotlin/hu/bme/sch/cmsch/component/tournament/TournamentController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package hu.bme.sch.cmsch.component.tournament | ||
|
|
||
| import tools.jackson.databind.ObjectMapper | ||
| import hu.bme.sch.cmsch.controller.admin.OneDeepEntityPage | ||
| import hu.bme.sch.cmsch.controller.admin.calculateSearchSettings | ||
| import hu.bme.sch.cmsch.service.AdminMenuService | ||
| import hu.bme.sch.cmsch.service.AuditLogService | ||
| import hu.bme.sch.cmsch.service.ImportService | ||
| import hu.bme.sch.cmsch.service.StaffPermissions | ||
| import hu.bme.sch.cmsch.service.StorageService | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnBean | ||
| import org.springframework.core.env.Environment | ||
| import org.springframework.stereotype.Controller | ||
| import org.springframework.transaction.PlatformTransactionManager | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
|
|
||
| @Controller | ||
| @RequestMapping("/admin/control/tournament") | ||
| @ConditionalOnBean(TournamentComponent::class) | ||
| class TournamentController( | ||
| private val tournamentService: TournamentService, | ||
| repo: TournamentRepository, | ||
| importService: ImportService, | ||
| adminMenuService: AdminMenuService, | ||
| component: TournamentComponent, | ||
| auditLog: AuditLogService, | ||
| objectMapper: ObjectMapper, | ||
| transactionManager: PlatformTransactionManager, | ||
| storageService: StorageService, | ||
| env: Environment | ||
| ) : OneDeepEntityPage<TournamentEntity>( | ||
| "tournament", | ||
| TournamentEntity::class, ::TournamentEntity, | ||
| "Verseny", "Versenyek", | ||
| "A rendezvény versenyeinek kezelése.", | ||
|
|
||
| transactionManager, | ||
| repo, | ||
| importService, | ||
| adminMenuService, | ||
| storageService, | ||
| component, | ||
| auditLog, | ||
| objectMapper, | ||
| env, | ||
|
|
||
| showPermission = StaffPermissions.PERMISSION_SHOW_TOURNAMENTS, | ||
| createPermission = StaffPermissions.PERMISSION_CREATE_TOURNAMENTS, | ||
| editPermission = StaffPermissions.PERMISSION_EDIT_TOURNAMENTS, | ||
| deletePermission = StaffPermissions.PERMISSION_DELETE_TOURNAMENTS, | ||
|
|
||
| createEnabled = true, | ||
| editEnabled = true, | ||
| deleteEnabled = true, | ||
| importEnabled = true, | ||
| exportEnabled = true, | ||
|
|
||
| adminMenuIcon = "sports_esports", | ||
| adminMenuPriority = 1, | ||
| searchSettings = calculateSearchSettings<TournamentEntity>(true) | ||
| ){ | ||
| override fun onEntityDeleted(entity: TournamentEntity) { | ||
| tournamentService.deleteStagesForTournament(entity) | ||
| super.onEntityDeleted(entity) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
compareTocompares mismatched fields, violating the Comparable contract.Line 20 compares
this.initialSeedagainstother.highestSeed— two different fields. This breaks transitivity. For example, with three teams all havingdetailedStats == null:-1.compareTo(5)→ negative → A < B-5.compareTo(1)→ negative → B < C-1.compareTo(1)→ zero → A == CA < B and B < C but A == C violates the transitivity requirement of
Comparable.🐛 Proposed fix — compare the same field on both sides
if (this.detailedStats == null && other.detailedStats == null) { - return -this.initialSeed.compareTo(other.highestSeed) + return -this.initialSeed.compareTo(other.initialSeed) }If the business intent is actually to compare
highestSeed, usethis.highestSeed.compareTo(other.highestSeed)instead. The key requirement is comparing the same field on both sides.📝 Committable suggestion
🤖 Prompt for AI Agents