mirror of
https://github.com/openziti/ziti.git
synced 2026-10-08 22:01:15 +00:00
623681db87
- as updates to API Sessions can now happen later than the last time they were active, updatedAt is no longer the correct representation of the last activity an API Session had - move all logic that used updatedAt to lastActivityAt - add migration to set lastActivityAt
20 lines
686 B
Go
20 lines
686 B
Go
package persistence
|
|
|
|
import (
|
|
"github.com/openziti/foundation/storage/ast"
|
|
"github.com/openziti/foundation/storage/boltz"
|
|
)
|
|
|
|
//Primes API Session's lastActivityAt proper to their previous updatedAt value
|
|
func (m *Migrations) setLastActivityAt(step *boltz.MigrationStep) {
|
|
for cursor := m.stores.ApiSession.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue); cursor.IsValid(); cursor.Next() {
|
|
if apiSession, err := m.stores.ApiSession.LoadOneById(step.Ctx.Tx(), string(cursor.Current())); err == nil {
|
|
apiSession.LastActivityAt = apiSession.UpdatedAt
|
|
m.stores.ApiSession.Update(step.Ctx, apiSession, UpdateLastActivityAtChecker{})
|
|
} else {
|
|
step.SetError(err)
|
|
return
|
|
}
|
|
}
|
|
}
|