This commit is contained in:
parent
9142e7993a
commit
f3b56bb7b7
@ -200,10 +200,14 @@ func (db *dbLayer) increasePlayerOnlineDuration(ctx context.Context, playerID st
|
|||||||
return db.execInTransaction(ctx, "UPDATE players SET online_duration = online_duration + $2 WHERE id = $1", playerID, onlineDurationSecond)
|
return db.execInTransaction(ctx, "UPDATE players SET online_duration = online_duration + $2 WHERE id = $1", playerID, onlineDurationSecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *dbLayer) updatePlayerLastOnline(ctx context.Context, playerID string, lastOnline time.Time) error {
|
func (db *dbLayer) updatePlayerLastLogin(ctx context.Context, playerID string, lastOnline time.Time) error {
|
||||||
return db.execInTransaction(ctx, "UPDATE players SET last_login = $2 WHERE id = $1", playerID, lastOnline.Format(time.RFC3339))
|
return db.execInTransaction(ctx, "UPDATE players SET last_login = $2 WHERE id = $1", playerID, lastOnline.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *dbLayer) updatePlayerLastLogout(ctx context.Context, playerID string, lastOnline time.Time) error {
|
||||||
|
return db.execInTransaction(ctx, "UPDATE players SET last_logout = $2 WHERE id = $1", playerID, lastOnline.Format(time.RFC3339))
|
||||||
|
}
|
||||||
|
|
||||||
func (db *dbLayer) increasePlayerDeath(ctx context.Context, playerID string, deaths int) error {
|
func (db *dbLayer) increasePlayerDeath(ctx context.Context, playerID string, deaths int) error {
|
||||||
return db.execInTransaction(ctx, "UPDATE players SET deaths = deaths + $2 WHERE id = $1", playerID, deaths)
|
return db.execInTransaction(ctx, "UPDATE players SET deaths = deaths + $2 WHERE id = $1", playerID, deaths)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (c *joinCommand) run(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = db.updatePlayerLastOnline(ctx, p.id, time.Now())
|
err = db.updatePlayerLastLogin(ctx, p.id, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
@ -111,6 +111,12 @@ func (c *quitCommand) run(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = db.updatePlayerLastLogout(ctx, p.id, time.Now())
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = db.increasePlayerOnlineDuration(ctx, p.id, time.Now().Sub(p.lastOnline))
|
err = db.increasePlayerOnlineDuration(ctx, p.id, time.Now().Sub(p.lastOnline))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user