Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjb committed Jul 9, 2024
1 parent 7a4ee55 commit c973d17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/engine/eval_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (e *executor) createOrUpdateEvalStatus(
logger.Err(err).Msg("error upserting rule alert details")
}

if flags.BoolFromProjectID(ctx, e.featureFlags, flags.EvalHistory, params.ProjectID) {
if flags.Bool(ctx, e.featureFlags, flags.EvalHistory, params.ProjectID.String()) {
// Log in the evaluation history tables
_, err = db.WithTransaction(e.querier, func(qtx db.ExtendQuerier) (uuid.UUID, error) {
evalID, err := e.historyService.StoreEvaluationStatus(
Expand Down
12 changes: 4 additions & 8 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package flags
import (
"context"

"github.com/google/uuid"
ofprovider "github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg"
"github.com/open-feature/go-sdk/openfeature"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -54,14 +53,11 @@ func BoolFromContext(ctx context.Context, client openfeature.IClient, feature Ex
return getBool(ctx, client, feature, fromContext(ctx))
}

// BoolFromProjectID evaluates the feature flag with respect to the specified project ID.
// This is useful when evaluating feature flags outside a request context.
func BoolFromProjectID(ctx context.Context, client openfeature.IClient, feature Experiment, projectID uuid.UUID) bool {
// Bool evaluates the feature flag with respect to the specified target value.
func Bool(ctx context.Context, client openfeature.IClient, feature Experiment, target string) bool {
ectx := openfeature.NewEvaluationContext(
projectID.String(),
map[string]interface{}{
"project": projectID.String(),
},
target,
map[string]any{},
)
return getBool(ctx, client, feature, ectx)
}
Expand Down

0 comments on commit c973d17

Please sign in to comment.