push 6 in 6 milestones

This commit is contained in:
Elio Bischof 2023-06-29 14:28:27 +02:00
parent ad13a65d1d
commit 3a338cdb44
No known key found for this signature in database
GPG Key ID: 7B383FDE4DDBF1BD
3 changed files with 39 additions and 23 deletions

View File

@ -290,7 +290,17 @@ func NewIsNullCond(column string) handler.Condition {
return handler.Condition{
Name: column,
ParameterOpt: func(string) string {
return fmt.Sprintf("%s IS NULL", column)
return " IS NULL"
},
}
}
func NewNotEqualCond(column, value string) handler.Condition {
return handler.Condition{
Name: column,
Value: value,
ParameterOpt: func(param string) string {
return fmt.Sprintf(" != %s", param)
},
}
}

View File

@ -100,13 +100,13 @@ func NewProjectionHandler(
reduceScheduledPseudoEvent: reduceScheduledPseudoEvent,
}
go func() {
go func(subscribe bool) {
<-initialized
if !h.reduceScheduledPseudoEvent {
if subscribe {
go h.subscribe(ctx)
}
go h.schedule(ctx)
}()
}(!h.reduceScheduledPseudoEvent)
return h
}

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"github.com/zitadel/zitadel/internal/repository/milestone"
@ -127,6 +128,7 @@ func (p *milestoneProjection) reducePushed(event eventstore.Event) (*handler.Sta
if !ok {
return nil, errors.ThrowInvalidArgumentf(nil, "HANDL-XJGXK", "reduce.wrong.event.type %s", milestone.PushedEventType)
}
if e.MilestoneType != milestone.InstanceDeleted {
return crdb.NewUpdateStatement(
event,
[]handler.Column{
@ -137,6 +139,13 @@ func (p *milestoneProjection) reducePushed(event eventstore.Event) (*handler.Sta
handler.NewCond(MilestoneColumnType, e.MilestoneType),
},
), nil
}
return crdb.NewDeleteStatement(
event,
[]handler.Condition{
handler.NewCond(MilestoneColumnInstanceID, event.Aggregate().InstanceID),
},
), nil
}
func (p *milestoneProjection) reduceInstanceAdded(event eventstore.Event) (*handler.Statement, error) {
@ -194,7 +203,6 @@ func (p *milestoneProjection) reduceProjectAdded(event eventstore.Event) (*handl
}
func (p *milestoneProjection) reduceUserTokenAdded(event eventstore.Event) (*handler.Statement, error) {
printEvent(event)
e, ok := event.(*user.UserTokenAddedEvent)
if !ok {
return nil, errors.ThrowInvalidArgumentf(nil, "HANDL-3xhJ7", "reduce.wrong.event.type %s", user.UserTokenAddedType)
@ -211,19 +219,17 @@ func (p *milestoneProjection) reduceUserTokenAdded(event eventstore.Event) (*han
crdb.NewIsNullCond(MilestoneColumnReachedDate),
},
),
/* crdb.AddUpdateStatement(
crdb.AddUpdateStatement(
[]handler.Column{
handler.NewCol(MilestoneColumnReachedDate, event.CreationDate()),
},
[]handler.Condition{
handler.NewCond(MilestoneColumnInstanceID, event.Aggregate().InstanceID),
handler.NewCond(MilestoneColumnType, milestone.AuthenticationSucceededOnApplication),
crdb.NewExpressionCond(func(param string) (clause string, needsParam bool) {
return fmt.Sprintf("%s")
}),
crdb.NewNotEqualCond(MilestoneColumnIgnoredProject, strings.Split(e.ApplicationID, "@")[0]),
crdb.NewIsNullCond(MilestoneColumnReachedDate),
},
),*/
),
), nil
}