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

Bugfix/Workaround for issue #319: split group_value by ',' for replac… #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tboegner
Copy link

…ement by defined resources.

Copy link
Member

@ypid ypid left a comment

Choose a reason for hiding this comment

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

Hi @tboegner

Thanks for the patch. It works functionally but as I was reviewing and writing a test for it, I noticed that this bug occurred because the implementation is badly designed. Apparently I missed that when I reviewed/merged the feature in v3.3.0 (2015). Working with regex on the generated prettified_group_value that we just generated from the tokens does not make sense. In this function, we are in the nice position that the oh_value is fully parsed and we can do more semantic things than just stupid regex.

Can you update this patch and hook into prettifySelector instead? Bonus points when you refactor the existing function part that deals with locale also. You seem interested in this feature so doing it in prettifySelector should make it much more stable.

@tboegner
Copy link
Author

tboegner commented Feb 3, 2020

Hi @ypid

I agree with you that this patch is not a nice solution. It is just a workaround for a problematic parsing result. The problem is, that the holiday token is not identified as "holiday" and is grouped together with the weekday. Afterwards the only possibility I see is splitting the group by the ',' and replacing the concerned parts.
In my opinion the clean solution should be made in getSelectorRange() to separate the holiday from the weekday. But this is also not easy since the holiday tokens don't have a significant type in the input data. The type is 'weekday' or undefined depending on the order of the tokens.

So I was not able to fix it in a clean way without spending too much time. It is absolutely OK, if you don't want to integrate the patch. Maybe there is a better solution in the future.

@ypid
Copy link
Member

ypid commented Feb 3, 2020

All right. I will leave the PR open then to track it. Thanks for spotting the bug and working on a patch :)

But this is also not easy since the holiday tokens don't have a significant type in the input data. The type is 'weekday' or undefined depending on the order of the tokens.

I agree. This is not so well designed in the spec. But it works in practice and I don’t think we can change it now.

@ypid ypid added the status/WIP label Feb 3, 2020
ypid added a commit to ypid/opening_hours.js that referenced this pull request Feb 18, 2020
@ypid ypid added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation. and removed status/WIP labels Oct 25, 2020
@tboegner tboegner requested a review from ypid January 7, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants