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

Now doesn't show food at Linsen if it is not the same week #132

Merged
merged 5 commits into from
Jul 31, 2024

Conversation

The1Penguin
Copy link
Contributor

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.

@@ -72,6 +70,19 @@ parse day =
>=> (.: "richText")
>=> (.: "root")
>=> (.: "children")
>=> (\v' ->
withObject "asd" (
Copy link

Choose a reason for hiding this comment

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

typo?

Copy link
Contributor Author

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

@The1Penguin The1Penguin requested a review from malmz June 26, 2024 20:59
@The1Penguin
Copy link
Contributor Author

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

Copy link
Contributor

@Rembane Rembane left a 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...

Comment on lines 78 to 80
>=> (\case
Nothing -> fail "Failed to index into richtext"
Just v -> pure v) . headMay
Copy link
Contributor

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:

Suggested change
>=> (\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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes sense

Comment on lines 82 to 86
>=> pure . (== pure day) . parseTime defaultTimeLocale "%d-%m-%Y"
>=> \case
True -> pure v'
False -> pure []))
>=> menuParser . (\v' -> if length v' >= 9 then v' else mempty)
Copy link
Contributor

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

Suggested change
>=> 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

Copy link
Contributor Author

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)

@Rembane
Copy link
Contributor

Rembane commented Jun 26, 2024

Oh, maybe some tests would be useful?

Copy link
Contributor

@Multipacker Multipacker left a comment

Choose a reason for hiding this comment

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

LGTM

@sora-jp sora-jp merged commit d536c7a into main Jul 31, 2024
1 check passed
@sora-jp sora-jp deleted the check-date-linsen branch July 31, 2024 20:36
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