Skip to content

Commit

Permalink
Add functions to update player status and clear bench in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
thereallukesimpson committed Mar 13, 2024
1 parent 6ad8666 commit 73dd259
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion benchmaterepositories/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "app.benchmate"
version = "0.0.7"
version = "0.0.8"

//repositories {
// google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ internal class Database(databaseDriverFactory: DatabaseDriverFactory) {
)
}
}

internal fun updatePlayerStatus(playerId: String, status: PlayerStatus, onBenchCount: Int) {
return dbQuery.updatePlayerStatus(playerId = playerId, playerStatus = status, onBenchCount = onBenchCount.toLong())
}

internal fun clearBenchCountAndPlayerStatus() {
return dbQuery.clearBenchCountAndPlayerStatus(playerStatus = PlayerStatus.NONE, onBenchCount = 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ interface PlayerRepository {
playerStatus: PlayerStatus,
onBenchCount: Int
)

suspend fun updatePlayerStatus(
playerId: String,
playerStatus: PlayerStatus,
onBenchCount: Int
)

suspend fun clearBenchCountAndPlayerStatus()
}

class RealPlayerRepository(databaseDriverFactory: DatabaseDriverFactory): PlayerRepository {
Expand Down Expand Up @@ -44,4 +52,12 @@ class RealPlayerRepository(databaseDriverFactory: DatabaseDriverFactory): Player
onBenchCount = onBenchCount
)
}

override suspend fun updatePlayerStatus(playerId: String, playerStatus: PlayerStatus, onBenchCount: Int) {
database.updatePlayerStatus(playerId, playerStatus, onBenchCount = onBenchCount)
}

override suspend fun clearBenchCountAndPlayerStatus() {
database.clearBenchCountAndPlayerStatus()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ VALUES(?, ?, ?, ?, ?);

selectAllPlayers:
SELECT Player.*
FROM Player;
FROM Player;

updatePlayerStatus:
UPDATE Player
SET playerStatus=?, onBenchCount=? WHERE playerId=?;

clearBenchCountAndPlayerStatus:
UPDATE Player
SET playerStatus=?, onBenchCount=?;

0 comments on commit 73dd259

Please sign in to comment.