Skip to content

Commit

Permalink
Feat/api (#21)
Browse files Browse the repository at this point in the history
* feat: perf for scoreboard

* feat: improve perf

* feat: improve perf

* feat: improve socket time

* feat: scoreboard weight

* fix: scoreboard event when start game

* feat: db logging

* feat: remove healthz logging

* feat: remove pg layer history

* feat: scoreboard log

* fix: all rooms broadvaster

* fix: subClient connect

* feat: weight score

* feat: weight score clamp

* feat: weight score optimizer

* fix: async order

* perf: order async

* feat: new weight score

* feat: abs weight
  • Loading branch information
PatrickChoDev authored Mar 30, 2024
1 parent aa99712 commit e54bbef
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions apps/server/src/models/history.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ export class GameHistoryRepository {
) {
const total = await this.redis.incrBy(`game::${game_id}::${key}`, vote)
this.redis.keys(`game::${game_id}::*`).then(async (keys) => {
const totalVote = await this.redis.mGet(keys).then((votes) =>
votes.reduce((acc, v) => acc + parseInt(v || '0'), 0),
) || 1
keys.forEach(async (k) => {
if (k !== `game::${game_id}::${key}`) {
const kTotal = parseInt(await this.redis.get(k) || '0')
const decrease = ((Math.floor((total - kTotal) * vote / totalVote)))
const decrease = ((Math.floor(Math.abs(total - kTotal) * vote / 100)))
const remain = kTotal - decrease
if (remain > 0) this.redis.decrBy(k, decrease)
}
Expand Down

0 comments on commit e54bbef

Please sign in to comment.