Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ramusus
Copy link
Contributor

@ramusus ramusus commented Jan 30, 2016

I don't know should we merge this PR into the core at this stage. May be there is way better to do the same. This is the way how is possible to integrate my package https://github.com/ramusus/reaction-filtration with current development branch of reaction core.
Guys, what do you think, Is there any better way to inject filtration functionality into the core?

@ramusus
Copy link
Contributor Author

ramusus commented Jan 30, 2016

Right now it adds link "Show Filters" into the bottom of the right side-bar on the product grid page only and allow reactive filtration for product grid output

@brent-hoover brent-hoover added blocked and removed ready labels Feb 2, 2016
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be removed in v0.12 both contentFor and the placement of this.

@aaronjudd
Copy link
Contributor

I don't think you need to do this, the v0.12 layout will allow you to inject these templates using a "layout". We can hold merging and review after v0.12...

@aaronjudd aaronjudd added this to the v0.13.0 milestone Feb 3, 2016
api.use("ongoworks:[email protected]");
api.use("ongoworks:[email protected]");
api.use("alanning:[email protected]");
api.use("tmeasday:[email protected]");
Copy link
Contributor

Choose a reason for hiding this comment

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

This package doesn't seem to be very well maintained,(source has deprecated Meteor code) and warns This package is designed primarily for correctness, not performance. That's why it's aimed at counting smaller datasets and keeping the count instantly up to date. Is this the best choice?

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 agree completely, this notice also make me hesitate about using it. I will try to find another way of getting reactive count value.

@ScyDev
Copy link
Contributor

ScyDev commented Feb 21, 2016

This doesn't work anymore with the latest code on development (yesterday).
Mainly because productGrid files have moved into another package, I guess.

@ramusus
Copy link
Contributor Author

ramusus commented Feb 21, 2016

@ScyDev I will fix it in short time

@ramusus
Copy link
Contributor Author

ramusus commented Feb 21, 2016

@ScyDev released 0.0.4 version, which is supports now version 0.12 of Reaction Core and updated this PR.

See instructions here how to enable "Show filters" link.

@newsiberian
Copy link
Contributor

@ramusus, I still not happy, because of how you're using check. Maybe we could transfer this pub to SS validation pattern? here. Then you could validate all your object for one time in one place. Good example how to use SS with complex objects could be found here

@ramusus
Copy link
Contributor Author

ramusus commented Feb 22, 2016

Yes, SS is good idea for this case and I agree, that validation and execution should be in separate places. May be there are package similar to ValidatedMethod, but for Publications

@ramusus
Copy link
Contributor Author

ramusus commented Feb 22, 2016

implemented validation using SS for productFilters argument in Products publication. Now format is more readable, thanks @newsiberian. Also added translations

* @return {Object} return product cursor
*/
Meteor.publish("Products", function (productScrollLimit, productFilters) {
check(productScrollLimit, Match.OneOf(null, undefined, Number));
Copy link
Contributor

Choose a reason for hiding this comment

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

We could simplify it like this:

const filters = new SimpleSchema({
  "shops": {type: [String], optional: true},
  "tag": {type: String, optional: true},
  "query": {type: String, optional: true},
  "visibility": {type: Boolean, optional: true},
  "details": {type: Object, optional: true},
  "details.key": {type: String},
  "details.value": {type: String},
  "price": {type: Object, optional: true},
  "price.min": {type: Number},
  "price.max": {type: Number},
  "weight": {type: Object, optional: true},
  "weight.min": {type: Number},
  "weight.max": {type: Number}
})

Meteor.publish("Products", function (productScrollLimit, productFilters) {
  new SimpleSchema({
    productScrollLimit: { type: Number, optional: true },
    productFilters: { type: filters, optional: true }
  }).validator()
...

I think it should work not only in validationMethod. see docs. We don't need try/catch. Need tests

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 already tried this and I learned, that we can not completely substitute check() with SS validator, because check package will throw error "not all arguments of publication are checked with check()".
And I like more verbose schema in my case, because it shows full structure of productFilters argument. Don't mistake ValidatedMethod with publication function. You are offering use the same strategy and imho this is right way, but there is no ValidatedPublication package for now, read here

Try/catch we need, because validate() throws ValidationError and inside publication will fails silently without and log message (for me that is strange). We need throw Meteor error again to stop continue publication with wrong format of arguments

Copy link
Contributor

Choose a reason for hiding this comment

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

I have a feeling that we can't use audit-arguments-check and SS.validator() within one app. here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can in the way I did. audit-arguments-check only need that all publication arguments were checked using check(). After we can validate structure of any argument using SS validate() and throw error if it's wrong

@brent-hoover
Copy link
Collaborator

We reviewed this PR in the weekly meeting but we were unable to ascertain whether it was ready to merge as it seems there is an ongoing conversation (which we encourage). We leaving this open pending resolving all issues.

In addition this still has Code Climate issues that must be resolved and resolve merge conflict.

brent-hoover added a commit that referenced this pull request Mar 1, 2016
code injection, integration with reaction-filtration
@brent-hoover brent-hoover merged commit 828252f into reactioncommerce:development Mar 1, 2016
@newsiberian
Copy link
Contributor

Hello, this PR was merged unfortunately 😄 , but anyway, I've merged it into PR #741, and modify products publication. We could open an issue to continue discussion about this pub modification if you want.

@aaronjudd
Copy link
Contributor

@newsiberian yes, we'll need to clean it up.. we'll review it today, patch as needed for and open a new issue for the publication updates.

aaronjudd pushed a commit that referenced this pull request Mar 1, 2016
This is not ready for inclusion.

Revert #743
@aaronjudd
Copy link
Contributor

@ramusus I've reverted this. I think we need to look at this more.
@newsiberian I reverted to an earlier Products publication, not sure if I missed updates for the flattened products..

aaronjudd pushed a commit that referenced this pull request Mar 8, 2016
Resolves #846
Resolves #870

- ReactionProduct.getProductPriceRange().priceRange updated to return
range, min, max.
- denormalize function updated to add price range, min, max
- PriceRange added to product schema
- Add filtering to the tags, as originally conceived for
#743
— allow for multiple tags in query params

The format is:
http://localhost:3000/reaction/tag/shop?price.min=100&price.max=200
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