Skip to content
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

Feature/add reducer alias for transform entities #209

Conversation

victorsingh
Copy link
Contributor

What: We want 'reducer' to be used as an alias for 'transform'

Why: Because a transform entity is just a cached reducer

How:

manager.addEntityType('reducer', EntityTransform)

Was added to the built in entity types.

Checklist:

  • Has Breaking changes
  • Documentation
  • Tests
  • Ready to be merged
  • Added username to all-contributors list

@coveralls
Copy link

coveralls commented Feb 6, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 606af39 on victorsingh:feature/add-reducer-alias-for-transform-entities into e3a03c3 on ViacomInc:master.

@@ -92,6 +93,7 @@ function create (spec) {
// supports currying
manager.resolve = Transform.resolve(manager)
// does not support currying
manager.reducer = _.partial(Transform.transform, manager)
Copy link
Contributor

@raingerber raingerber Feb 7, 2018

Choose a reason for hiding this comment

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

we don't need this line, because it's adding a new function to the api, which is not part of issue #209

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the unit tests in core.test.js fails without this line of code

Copy link
Contributor

Choose a reason for hiding this comment

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

All the tests on master are currently passing. If you're referring to the test that you added specifically for this line, that test should also be removed when this line is deleted.

Copy link
Collaborator

@paulmolluzzo paulmolluzzo left a comment

Choose a reason for hiding this comment

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

Left a few small comments, but would like if this PR added more tests to ensure that reducer entities work properly. Since it'll effectively duplicate the coverage maybe we don't need much, but we should at least check some of the lifecycle methods are working on this entity type.

If there is a plan to deprecate transform entities in favor of reducer, everything will have to be tested so we don't lose code coverage. That can probably wait though.

@@ -82,6 +82,9 @@
"avatar_url": "https://avatars2.githubusercontent.com/u/16357592?v=4",
"profile": "https://github.com/victorsingh",
"contributions": [
"code",
"doc",
"test",
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

@@ -1510,6 +1510,42 @@ dataPoint.addEntities({
```
</details>

Note: We recommend using reducer as an alias for transform
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add backticks around the names?

We recommend using reducer as an alias for transform.

Also, is there a plan to deprecate the transform entity type entirely? If that's true it should be mentioned. Also, we might want to put a deprecation notice in the console or something when it's used. It's good to provide advanced notice if we can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The plan according to the PR is to move away from transform and towards using reducer from what I understand. So it makes sense to add a console warning. Thanks 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure the best place for the warning. @acatl or @raingerber?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if @acatl wants to deprecate transform or not - but if we do, I think it's enough to mention that in the readme (i.e. this will be deprecated in the future) because we would be providing a codemod to make the deprecation as easy as possible

@@ -1510,6 +1510,42 @@ dataPoint.addEntities({
```
</details>

Note: We recommend using reducer as an alias for transform

The following example produces the same result as its reducer counterpart:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment about backticks around reducer.

@paulmolluzzo paulmolluzzo added this to the v2 - new features milestone Feb 9, 2018
@@ -1462,24 +1462,30 @@ To customize type checking you may use a [Reducer](#reducers). If the reducer th
</details>


#### <a name="transform-entity">Transform Entity</a>
#### <a name="reducer-entity">Reducer Entity</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that this line is in another section of the readme:

for all entites except transform

do you mind replacing that sentence with:

for all entities except [Reducer](#reducer-entity)
?

@raingerber
Copy link
Contributor

@paulmolluzzo Has victor addressed the changes that you requested?

@paulmolluzzo
Copy link
Collaborator

@raingerber yup, all good!

Thanks @victorsingh! 🙌

@acatl acatl merged commit 64f5e54 into ViacomInc:master Feb 14, 2018
victorsingh pushed a commit to victorsingh/data-point that referenced this pull request Feb 15, 2018
…acomInc#209)

- Added reducer alias to the documentation for transform entity
- Updated .all-contributorsrc
- Improved documentation
- Updated Accumulator documentation for Reducer Entity

closes ViacomInc#167
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.

None yet

5 participants