Archive pokememes
This commit is contained in:
@@ -150,6 +150,15 @@ func (dc *DataCache) UpdatePlayerTimestamp(playerID int) error {
|
||||
dc.playersMutex.Unlock()
|
||||
return err
|
||||
}
|
||||
dc.squadsMutex.Lock()
|
||||
for i := range dc.squadPlayers {
|
||||
for j := range dc.squadPlayers[i] {
|
||||
if dc.squadPlayers[i][j].Player.ID == playerID {
|
||||
dc.squadPlayers[i][j].Player = *dc.players[playerID]
|
||||
}
|
||||
}
|
||||
}
|
||||
dc.squadsMutex.Unlock()
|
||||
dc.playersMutex.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ func (dc *DataCache) initPokememes() {
|
||||
func (dc *DataCache) loadPokememes() {
|
||||
c.Log.Info("Load current Pokememes data from database to DataCache...")
|
||||
pokememes := []dbmapping.Pokememe{}
|
||||
err := c.Db.Select(&pokememes, "SELECT * FROM pokememes")
|
||||
err := c.Db.Select(&pokememes, "SELECT * FROM pokememes WHERE is_active=1")
|
||||
if err != nil {
|
||||
// This is critical error and we need to stop immediately!
|
||||
c.Log.Fatal(err.Error())
|
||||
|
@@ -64,6 +64,16 @@ func (dc *DataCache) AddProfile(profile *dbmapping.Profile) (int, error) {
|
||||
dc.currentProfilesMutex.Lock()
|
||||
dc.profiles[insertedProfile.ID] = &insertedProfile
|
||||
dc.currentProfiles[insertedProfile.PlayerID] = &insertedProfile
|
||||
|
||||
dc.squadsMutex.Lock()
|
||||
for i := range dc.squadPlayers {
|
||||
for j := range dc.squadPlayers[i] {
|
||||
if dc.squadPlayers[i][j].Player.ID == insertedProfile.PlayerID {
|
||||
dc.squadPlayers[i][j].Profile = insertedProfile
|
||||
}
|
||||
}
|
||||
}
|
||||
dc.squadsMutex.Unlock()
|
||||
dc.currentProfilesMutex.Unlock()
|
||||
dc.profilesMutex.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user