mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
dd5e4acd24
* start sub * start implement subsciptions * start subscription * implementation for member done * admin done * fix: tests * extend handlers * prepary notification * no errors in adminapi * changed current sequence in all packages * ignore mocks * works * subscriptions as singleton * tests * refactor: rename function scope var
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package view
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
)
|
|
|
|
const (
|
|
sequencesTable = "authz.current_sequences"
|
|
)
|
|
|
|
func (v *View) saveCurrentSequence(viewName string, event *models.Event) error {
|
|
return repository.SaveCurrentSequence(v.Db, sequencesTable, viewName, string(event.AggregateType), event.Sequence, event.CreationDate)
|
|
}
|
|
|
|
func (v *View) latestSequence(viewName, aggregateType string) (*repository.CurrentSequence, error) {
|
|
return repository.LatestSequence(v.Db, sequencesTable, viewName, aggregateType)
|
|
}
|
|
|
|
func (v *View) updateSpoolerRunSequence(viewName string) error {
|
|
currentSequence, err := repository.LatestSequence(v.Db, sequencesTable, viewName, "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if currentSequence.ViewName == "" {
|
|
currentSequence.ViewName = viewName
|
|
}
|
|
currentSequence.LastSuccessfulSpoolerRun = time.Now()
|
|
//update all aggregate types
|
|
//TODO: not sure if all scenarios work as expected
|
|
currentSequence.AggregateType = ""
|
|
return repository.UpdateCurrentSequence(v.Db, sequencesTable, currentSequence)
|
|
}
|