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

Move consistency checkers to a class #181

Closed

Conversation

fonsecadeline
Copy link
Contributor

VRP validation was getting too long and mixed. I think we had discussed doing this in the meantime of [I do not remember what].

In any case that would help to have a cleaner base for future developments

models/hash_validator.rb Outdated Show resolved Hide resolved
models/hash_validator.rb Outdated Show resolved Hide resolved
models/hash_validator.rb Outdated Show resolved Hide resolved
models/hash_validator.rb Outdated Show resolved Hide resolved
@fonsecadeline fonsecadeline force-pushed the move_consistency_checkers branch 5 times, most recently from 7b865aa to 2e00eea Compare April 14, 2021 09:57
@senhalil senhalil added this to the v1.8 milestone Apr 15, 2021
@fonsecadeline fonsecadeline mentioned this pull request Apr 15, 2021
@@ -124,7 +126,7 @@ def self.create(hash, delete = true)
vrp = super({})
self.filter(hash) # TODO : add filters.rb here
# moved filter here to make sure we do have schedule_indices (not date) to do work_day check with lapses
self.check_consistency(hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't really concern the VRP, but the hash. I am not convinced at all that it should be a concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would you suggest ? We had previously created a class that validates Hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have in input a JSON received by grape, which converts it into an hash, this hash is then converted into a vrp model using active_hash.

My assumption is that, the intermediate hash should have is own class which inherit from hash and add the concern to it.
so we could directly call hash.check_consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

@fonsecadeline the class you proposed was completely different -- it was in Models module and inhereted from Vrp class, -- the class @braktar suggests is a lot straightforward and it is kind of a wrapper around Hash class so that you can add the concern to that class.

I am still not convinced that it worth the effort because the main reason we have these validations like this (i.e., manually) is that the validation functionality validates_x_of_y of active_hash(?) was broken in the previous Ruby version. We still haven't tested if it is still broken or not in the current Ruby version. This functionality also lets us define custom validators and it calls them automatically, and (if I am not mistaken) it gives clear fail messages with indexing etc. so our manual validators are temporary at best.

This would make more sense if we could use this custom Hash to tell Grape to use as validator (kinda like presenter + validation) but I don't think we can do that.

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 that this is meant to be temporary and maybe we do not need to spend too much time trying to make it in the best way.

What should I do then ? are we okay to keep it like that ? (#192)

@fonsecadeline
Copy link
Contributor Author

Split_clustering_tests fail because we added a check : there can not be more than one visit if there is no schedule. Visits are considered a little differently in max_split algo so 7 tests fail now.

@fonsecadeline
Copy link
Contributor Author

Real scheduling cases should be okay after we merge #191

@fonsecadeline
Copy link
Contributor Author

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