Skip to content

Commit

Permalink
Fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
patapancakes committed May 21, 2024
1 parent f8f5aef commit 7bfd9df
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/savedata/clear.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Clear(uuid []byte, slot int, seed string, save defs.SessionSaveData) (Clear
}

if save.Score >= 20000 {
db.SetAccountLimited(uuid, true)
db.SetAccountBanned(uuid, true)
}

err = db.AddOrUpdateAccountDailyRun(uuid, save.Score, waveCompleted)
Expand Down
2 changes: 1 addition & 1 deletion api/savedata/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Update(uuid []byte, slot int, save any) error {
save.VoucherCounts["1"] > 150 ||
save.VoucherCounts["2"] > 100 ||
save.VoucherCounts["3"] > 10 {
db.SetAccountLimited(uuid, true)
db.SetAccountBanned(uuid, true)
}

err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
Expand Down
4 changes: 2 additions & 2 deletions db/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func UpdateAccountStats(uuid []byte, stats defs.GameStats, voucherCounts map[str
return nil
}

func SetAccountLimited(uuid []byte, limited bool) error {
_, err := handle.Exec("UPDATE accounts SET limited = ? WHERE uuid = ?", limited, uuid)
func SetAccountBanned(uuid []byte, banned bool) error {
_, err := handle.Exec("UPDATE accounts SET banned = ? WHERE uuid = ?", banned, uuid)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions db/daily.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func FetchRankings(category int, page int) ([]defs.DailyRanking, error) {
var query string
switch category {
case 0:
query = "SELECT RANK() OVER (ORDER BY adr.score DESC, adr.timestamp), a.username, adr.score, adr.wave FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date = UTC_DATE() AND a.limited = 0 LIMIT 10 OFFSET ?"
query = "SELECT RANK() OVER (ORDER BY adr.score DESC, adr.timestamp), a.username, adr.score, adr.wave FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date = UTC_DATE() AND a.banned = 0 LIMIT 10 OFFSET ?"
case 1:
query = "SELECT RANK() OVER (ORDER BY SUM(adr.score) DESC, adr.timestamp), a.username, SUM(adr.score), 0 FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date >= DATE_SUB(DATE(UTC_TIMESTAMP()), INTERVAL DAYOFWEEK(UTC_TIMESTAMP()) - 1 DAY) AND a.limited = 0 GROUP BY a.username ORDER BY 1 LIMIT 10 OFFSET ?"
query = "SELECT RANK() OVER (ORDER BY SUM(adr.score) DESC, adr.timestamp), a.username, SUM(adr.score), 0 FROM accountDailyRuns adr JOIN dailyRuns dr ON dr.date = adr.date JOIN accounts a ON adr.uuid = a.uuid WHERE dr.date >= DATE_SUB(DATE(UTC_TIMESTAMP()), INTERVAL DAYOFWEEK(UTC_TIMESTAMP()) - 1 DAY) AND a.banned = 0 GROUP BY a.username ORDER BY 1 LIMIT 10 OFFSET ?"
}

results, err := handle.Query(query, offset)
Expand Down

0 comments on commit 7bfd9df

Please sign in to comment.