Skip to content

Add new constraint operators #192

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 13 commits into from
Mar 4, 2022
Merged

Conversation

ivanklee86
Copy link
Collaborator

@ivanklee86 ivanklee86 commented Feb 4, 2022

Description

Supports new operators outlined in #191 .

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Unit tests
  • Spec Tests
  • Integration tests / Manual Tests

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivanklee86 ivanklee86 requested a review from ivarconr February 4, 2022 11:01
@coveralls
Copy link

coveralls commented Feb 4, 2022

Coverage Status

Coverage increased (+0.2%) to 96.259% when pulling 23d945c on 191_add_new_constraint_operators into 01d7d2d on main.

context.update(self.unleash_static_context)

# Update context with optional values
if 'currentTime' not in context.keys():
context.update({'currentTime': datetime.now()})
Copy link
Member

Choose a reason for hiding this comment

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

I might need to steal this to the Node.SDK.

The only reason I kept this in the operator itself is that it does give an additional cost for every isEnabled call to create currentTime instance, even if it is mostly not needed (which will be 99% of the cases). On the other hand, datetime.now() probably has an insignificant cost?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tldr after a few rabbit holes: Yes for modern CPUs.

I was mainly putting it there since it seemed that it might be handy for other uses (on reflection though, not 100% sure what those could be). I'd be OK with moving this into the Constraint check.

Do you think you'd use currentTime in other features?

Copy link
Member

Choose a reason for hiding this comment

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

not sure yet. I do not see a big issue moving it out to the context creation later if we find use for it. I would prefer us to have it in the constraint for now.

Copy link
Collaborator Author

@ivanklee86 ivanklee86 Mar 4, 2022

Choose a reason for hiding this comment

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

self.context_name: str = constraint_dict['contextName']
self.operator: ConstraintOperators = ConstraintOperators(constraint_dict['operator'].upper())
self.values = constraint_dict['values'] if 'values' in constraint_dict.keys() else []
self.value = constraint_dict['value'] if 'value' in constraint_dict.keys() else []
Copy link
Member

@ivarconr ivarconr Feb 9, 2022

Choose a reason for hiding this comment

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

else [] seems a bit weird for a string?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe None is better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whoops, that's an embarassing C/P error. Def. should be None!

@ivanklee86 ivanklee86 merged commit b34d891 into main Mar 4, 2022
@ivanklee86 ivanklee86 deleted the 191_add_new_constraint_operators branch March 4, 2022 10:58
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.

3 participants