mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-15 03:07:36 +00:00
push human readable milestone type
This commit is contained in:
@@ -2,7 +2,6 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -77,17 +76,7 @@ func (t *telemetryPusher) reducers() []handler.AggregateReducer {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
|
||||||
func printEvent(event eventstore.Event) {
|
|
||||||
bytes, err := json.MarshalIndent(event, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
fmt.Println(event.Type(), string(bytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *telemetryPusher) pushMilestones(event eventstore.Event) (*handler.Statement, error) {
|
func (t *telemetryPusher) pushMilestones(event eventstore.Event) (*handler.Statement, error) {
|
||||||
printEvent(event)
|
|
||||||
ctx := call.WithTimestamp(context.Background())
|
ctx := call.WithTimestamp(context.Background())
|
||||||
scheduledEvent, ok := event.(*pseudo.ScheduledEvent)
|
scheduledEvent, ok := event.(*pseudo.ScheduledEvent)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -133,7 +122,7 @@ func (t *telemetryPusher) pushMilestones(event eventstore.Event) (*handler.State
|
|||||||
|
|
||||||
func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.ScheduledEvent, ms *query.Milestone) error {
|
func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.ScheduledEvent, ms *query.Milestone) error {
|
||||||
ctx = authz.WithInstanceID(ctx, ms.InstanceID)
|
ctx = authz.WithInstanceID(ctx, ms.InstanceID)
|
||||||
alreadyHandled, err := t.queries.IsAlreadyHandled(ctx, event, map[string]interface{}{"type": ms.Type}, milestone.AggregateType, milestone.PushedEventType)
|
alreadyHandled, err := t.queries.IsAlreadyHandled(ctx, event, map[string]interface{}{"type": ms.Type.String()}, milestone.AggregateType, milestone.PushedEventType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ func applyCustomConfig(config crdb.StatementHandlerConfig, customConfig CustomCo
|
|||||||
// as setup and start currently create them individually, we make sure we get the right one
|
// as setup and start currently create them individually, we make sure we get the right one
|
||||||
// will be refactored when changing to new id based projections
|
// will be refactored when changing to new id based projections
|
||||||
//
|
//
|
||||||
// Event handlers NotificationsProjection, NotificationsQuotaProjection and NotificationsProjection are not added here, because the do not statement based / have no proprietary projection table
|
// Event handlers NotificationsProjection, NotificationsQuotaProjection and NotificationsProjection are not added here, because they do not reduce to database statements
|
||||||
func newProjectionsList() {
|
func newProjectionsList() {
|
||||||
projections = []projection{
|
projections = []projection{
|
||||||
OrgProjection,
|
OrgProjection,
|
||||||
|
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
package milestone
|
package milestone
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type Type int
|
type Type int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -24,3 +29,31 @@ func AllTypes() []Type {
|
|||||||
}
|
}
|
||||||
return types
|
return types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Type) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(fmt.Sprintf(`"%s"`, t.String())), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Type) UnmarshalJSON(data []byte) error {
|
||||||
|
*t = typeFromString(strings.Trim(string(data), `"`))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func typeFromString(t string) Type {
|
||||||
|
switch t {
|
||||||
|
case InstanceCreated.String():
|
||||||
|
return InstanceCreated
|
||||||
|
case AuthenticationSucceededOnInstance.String():
|
||||||
|
return AuthenticationSucceededOnInstance
|
||||||
|
case ProjectCreated.String():
|
||||||
|
return ProjectCreated
|
||||||
|
case ApplicationCreated.String():
|
||||||
|
return ApplicationCreated
|
||||||
|
case AuthenticationSucceededOnApplication.String():
|
||||||
|
return AuthenticationSucceededOnApplication
|
||||||
|
case InstanceDeleted.String():
|
||||||
|
return InstanceDeleted
|
||||||
|
default:
|
||||||
|
return unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user