Skip to content

Conversation

@yasirfolio3
Copy link
Contributor

@yasirfolio3 yasirfolio3 commented Oct 19, 2022

Summary

  • Parse new integrations section of the datafile
  • Evaluate() using UserContext

Test plan

  • All new and previous tests should pass

Issues

FSSDK-8518

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial review. need to check matcher conditions code.

"fmt"
"time"

"github.com/optimizely/go-sdk"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the need?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was forced by linter since we are using optimizely keyword to access the package in the sample code.

return attributesCopy
}

func copyQualifiedSegments(qualifiedSegments []string) (qualifiedSegmentsCopy []string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check offline.


import (
"io/ioutil"
"os"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested by linter as "io/ioutil is now depreceated in go 1.16 onwards.

var hostForODP, publicKeyForODP string
if len(datafile.Integrations) > 0 {
integration := datafile.Integrations[0]
if integration.Key == "odp" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird, can we 'iterate integrationsand checkodp, assign it and get out of loop`

experimentIDMap, experimentKeyMap := mappers.MapExperiments(allExperiments, experimentGroupMap)

rollouts, rolloutMap := mappers.MapRollouts(datafile.Rollouts)
integrations := mappers.MapIntegrations(datafile.Integrations)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this map? integrationsMap?

)

// MapIntegrations maps the raw datafile integration entities to SDK Integration entities
func MapIntegrations(integrations []datafileEntities.Integration) (integrationsList []entities.Integration) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a map, simple list either return map along with list or no need of this method.

reasons := decide.NewDecisionReasons(options)
if condition.Type != customAttributeType {
isValid := false
for _, validType := range validTypes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why nchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from yasir/lru-cache to master October 20, 2022 05:10
@yasirfolio3 yasirfolio3 reopened this Oct 20, 2022
Copy link

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. A few changes suggested.

Comment on lines 102 to 104
if qualifiedSegments == nil {
qualifiedSegments = []string{}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qualifiedSegments are nullable. When null, it indicates non-determined (fetchSegments are not completed yet). Empty segments is valid one (fetchSegments returns an empty list).

return OptimizelyUserContext{
UserID: userID,
Attributes: attributesCopy,
qualifiedSegments: []string{},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why passing empty array instead of a copy of current qualifiedSegments?

type DatafileProjectConfig struct {
datafile string
hostForODP string
publicKeyForODP string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that a logic to get all segments used in datafile audiences is missing. We need it later when we call fetchSegments. See https://github.com/optimizely/swift-sdk/blob/ec83c87d53b17ea58f8c73eb581b27fa52b6305c/Sources/Data%20Model/ProjectConfig.swift#L151

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally holding it off for the next PR but have now implemented it in this one. Please have a look at the new changes.

2. Suggested changes made.
Copy link

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@msohailhussain msohailhussain merged commit f6b91bc into master Nov 7, 2022
@msohailhussain msohailhussain deleted the yasir/datafile-parsing-audience-evaluation branch November 7, 2022 06:22
audience.ConditionTree = conditionTree
}

for _, s := range fSegments {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants