mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
81efd86a8d
* fix: improve db call when only count is required (old views) * Update query.go
28 lines
795 B
Go
28 lines
795 B
Go
package eventstore
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/api/authz"
|
|
"github.com/caos/zitadel/internal/auth/repository/eventsourcing/view"
|
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
|
)
|
|
|
|
type UserSessionRepo struct {
|
|
View *view.View
|
|
}
|
|
|
|
func (repo *UserSessionRepo) GetMyUserSessions(ctx context.Context) ([]*usr_model.UserSessionView, error) {
|
|
userSessions, err := repo.View.UserSessionsByAgentID(authz.GetCtxData(ctx).AgentID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return model.UserSessionsToModel(userSessions, repo.View.PrefixAvatarURL()), nil
|
|
}
|
|
|
|
func (repo *UserSessionRepo) ActiveUserSessionCount() int64 {
|
|
userSessions, _ := repo.View.ActiveUserSessionsCount()
|
|
return int64(userSessions)
|
|
}
|