i hate sql!!!!

This commit is contained in:
Jill 2023-01-05 12:28:41 +03:00
parent ab88dba7e0
commit 0417f36d3a
1 changed files with 1 additions and 1 deletions

View File

@ -35,7 +35,7 @@ def claim_chest(account_id : Int32, prev_count : Int32, large = false)
timer = config_get("chests.#{large ? "large" : "small"}.timer").as?(Int64) || 0
next_at = (Time.utc + timer.seconds).to_s(Format::TIME_FORMAT)
if DATABASE.scalar("select count(*) from #{table}").as(Int64) > 0
DATABASE.exec("update #{table} set total_opened = ?, next_at = ?", prev_count + 1, next_at)
DATABASE.exec("update #{table} set total_opened = ?, next_at = ? where account_id = ?", prev_count + 1, next_at, account_id)
else
DATABASE.exec("insert into #{table} (account_id, total_opened, next_at) values (?, ?, ?)", account_id, prev_count + 1, next_at)
end