-
Notifications
You must be signed in to change notification settings - Fork 9
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
Now doesn't show food at Linsen if it is not the same week #132
Conversation
src/Model/Linsen.hs
Outdated
@@ -72,6 +70,19 @@ parse day = | |||
>=> (.: "richText") | |||
>=> (.: "root") | |||
>=> (.: "children") | |||
>=> (\v' -> | |||
withObject "asd" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really matter
Reason for the change from checking week to checking date is that the "API" is not consistent with the format of weeks, but is consistent on date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I have some suggestions in the comments that are super optional, but I had to write them down somewhere...
src/Model/Linsen.hs
Outdated
>=> (\case | ||
Nothing -> fail "Failed to index into richtext" | ||
Just v -> pure v) . headMay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as:
>=> (\case | |
Nothing -> fail "Failed to index into richtext" | |
Just v -> pure v) . headMay | |
>=> \case | |
[] -> fail "Failed to index into richtext" | |
(v:_) -> pure v |
...which removes one import and doesn't shift over into the realm of Maybes but stays in the list dimension. It's very much up to you how you want to do this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense
src/Model/Linsen.hs
Outdated
>=> pure . (== pure day) . parseTime defaultTimeLocale "%d-%m-%Y" | ||
>=> \case | ||
True -> pure v' | ||
False -> pure [])) | ||
>=> menuParser . (\v' -> if length v' >= 9 then v' else mempty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, due to me being way too tired my brain fired up the pattern recognition module and went to town, so the changes proposed below are kinda optional. :D
>=> pure . (== pure day) . parseTime defaultTimeLocale "%d-%m-%Y" | |
>=> \case | |
True -> pure v' | |
False -> pure [])) | |
>=> menuParser . (\v' -> if length v' >= 9 then v' else mempty) | |
>=> \s -> if pure day == parseTime defaultTimeLocale "%d-%m-%Y" s | |
&& length v' >= 9 | |
then pure v' | |
else mempty)) | |
>=> menuParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this, but pure mempty
instead of mempty
since menuParser
still expects a list (Test failed when it wasn't so I take their word for it)
Oh, maybe some tests would be useful? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As we all have seen; Linsen shows food that was served last week, and this is not okay. This little fix would solve that issue.