mirror of
https://github.com/zitadel/zitadel
synced 2024-11-22 00:39:36 +00:00
7967e6f98b
# Which Problems Are Solved Improve the performance of human imports by optimizing the query that finds domains claimed by other organizations. # How the Problems Are Solved Use the fields search table introduced in https://github.com/zitadel/zitadel/pull/8191 by storing each organization domain as Object ID and the verified status as field value. # Additional Changes - Feature flag for this optimization # Additional Context - Performance improvements for import are evaluated and acted upon internally at the moment --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package setup
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/query/projection"
|
|
"github.com/zitadel/zitadel/internal/repository/instance"
|
|
)
|
|
|
|
type FillFieldsForOrgDomainVerified struct {
|
|
eventstore *eventstore.Eventstore
|
|
}
|
|
|
|
func (mig *FillFieldsForOrgDomainVerified) Execute(ctx context.Context, _ eventstore.Event) error {
|
|
instances, err := mig.eventstore.InstanceIDs(
|
|
ctx,
|
|
0,
|
|
true,
|
|
eventstore.NewSearchQueryBuilder(eventstore.ColumnsInstanceIDs).
|
|
OrderDesc().
|
|
AddQuery().
|
|
AggregateTypes("instance").
|
|
EventTypes(instance.InstanceAddedEventType).
|
|
Builder(),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, instance := range instances {
|
|
ctx := authz.WithInstanceID(ctx, instance)
|
|
if err := projection.OrgDomainVerifiedFields.Trigger(ctx); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (mig *FillFieldsForOrgDomainVerified) String() string {
|
|
return "30_fill_fields_for_org_domain_verified"
|
|
}
|