Skip to content

feat(api): Accepting all types for attributes values #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 26, 2018

Conversation

rashidsp
Copy link
Contributor

@rashidsp rashidsp commented Sep 17, 2018

Note:

Helpers::Constants::ATTRIBUTE_VALID_TYPES.any? { |type| attribute_value.is_a?(type) }

ATTRIBUTE_VALID_TYPES.include?(attribute_value.class) can't be used as Fixnum and Bignum are deprecated in ruby 2.4 and Rubocop fails: Lint/UnifiedInteger: Use Integer instead of Fixnum.

@coveralls
Copy link

coveralls commented Sep 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling c5fedb3 on rashid/attribute-types into a760fdb on master.

@mikeproeng37
Copy link
Contributor

Going to wait on this until we resolve and merge the Python PR, then we should make sure this matches the requirements over there as well @msohailhussain

@msohailhussain
Copy link
Contributor

build

@@ -74,9 +76,9 @@ def get_common_params(user_id, attributes)
visitor_attributes = []

attributes&.keys&.each do |attribute_key|
# Omit null attribute values
# Omit invalid attribute values.
Copy link
Contributor

Choose a reason for hiding this comment

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

correct comment is "Omit attribute values that are not supported by the log endpoint."
we need to check attribute key is string or not?

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

Mostly good. Just have a few comments

@@ -145,4 +145,19 @@
condition = JSON.parse(condition)
expect(@condition_evaluator.evaluate(condition)).to be true
end

it 'should evaluate to true for evaluate when user attributes evaluate true' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you re-word this: should evaluate to true when user attributes match the audience conditions

@@ -125,6 +125,70 @@
expect(impression_event.http_verb).to eq(:post)
end

it 'should create a valid Event when create_impression_event is called with attributes of different valid types' do
@expected_impression_params[:visitors][0][:attributes].unshift(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you copy this into a new variable and mutate that one for use instead?

end

it 'should create a valid Event and exclude attributes of invalid types' do
@expected_impression_params[:visitors][0][:attributes].unshift(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

lgtm, just have a small suggestion

bucketing_id = attributes[Optimizely::Helpers::Constants::CONTROL_ATTRIBUTES['BUCKETING_ID']]
@config.logger.log(Logger::DEBUG, "Setting the bucketing ID '#{bucketing_id}'")
end
attributes ||= {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's return the user_id if attributes is not defined or null

@mikeproeng37
Copy link
Contributor

@rashidsp looks like the test failures are legit. There are some lint errors.

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

Setting to revise so that rebase issues could be resolved and @mikeng13 's feedback be addressed

@mikeproeng37 mikeproeng37 merged commit ff19d0a into master Nov 26, 2018
@oakbani oakbani deleted the rashid/attribute-types branch November 27, 2018 11:42
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.

5 participants