Skip to content

Commit

Permalink
akka-loader: no upload entry for the empty load
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackmorse committed Feb 28, 2024
1 parent ad56891 commit 6d7471b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions akka-loader/src/main/scala/clickhouse/HattidClickhouseClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,19 @@ class HattidClickhouseClient @Inject()(val config: Config,
val round = realRound(matchType, league)
val season = league.season - league.seasonOffset
val isLeagueMatch = if (matchType == MatchType.LEAGUE_MATCH) 1 else 0
client.execute(s"INSERT INTO $databaseName.upload_history (league_id, season, round, is_league_match) VALUES " +
s" (${league.leagueId}, $season, $round, $isLeagueMatch)")

val cupLevelIndexCondition = if(matchType == MatchType.LEAGUE_MATCH) " cup_level_index = 0 " else " cup_level_index != 0 "
val countFuture = client.query(s"select count() from $databaseName.match_details where season = $season and " +
s"round = $round and league_id = ${league.leagueId} and $cupLevelIndexCondition")
val count = Await.result(countFuture, 30.seconds).trim.replace("\n", "").replace("\r", "")

if (count != "0") {
client.execute(s"INSERT INTO $databaseName.upload_history (league_id, season, round, is_league_match) VALUES " +
s" (${league.leagueId}, $season, $round, $isLeagueMatch)")
} else {
logger.info(s"No data was uploaded for league ${league.leagueId} (${league.leagueName})")
Future(())
}
}

def checkUploaded(league: League, matchType: MatchType.Value): Boolean = {
Expand Down

0 comments on commit 6d7471b

Please sign in to comment.