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

[#119] Refactor set-field in CLI and WebAPI #130

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sancho20021
Copy link
Contributor

@sancho20021 sancho20021 commented Aug 1, 2022

Description

Problem: currently set-field is used both for changing visibility
and setting new fields. This results in additional handling of the
situation where both field contents and visibility option are missing.

Solution: require contents for setting field and allow changing
visibility for convenience. Add set-field-visibility command in CLI and route in WebAPI
which modifies only visibility.

Related issue(s)

Fixes #119

✅ Checklist for your Pull Request

Related changes (conditional)

  • Tests

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:

Stylistic guide (mandatory)

Problem: `set-field` route was used both for changing visibility
and setting fields. This resulted in ambiguous behavior in case
of missing contents and visibility options.

Solution: require contents for setting field and allow changing
visibility for convenience. Add `set-field-visibility` request
which doesn't require field contents.
@sancho20021 sancho20021 requested a review from Kariel-Myrr August 1, 2022 15:35
Copy link
Contributor

@Kariel-Myrr Kariel-Myrr left a comment

Choose a reason for hiding this comment

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

LGTM
(not touching Web part)

app/cli/Main.hs Outdated
res@SFRSuccess{} -> printSuccess $ buildSetFieldResult CLI res


Copy link
Contributor

Choose a reason for hiding this comment

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

extra \n

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

updateOrInsertField :: UTCTime -> Maybe Field -> Sem r (Maybe Field)
updateOrInsertField nowUtc = \case
updateOrInsertField :: UTCTime -> Maybe Field -> Field
updateOrInsertField nowUtc fieldMb = case fieldMb of
Copy link
Contributor

Choose a reason for hiding this comment

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

\case?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks

@@ -125,23 +134,29 @@ reportErrors io = do
Right (Right a) -> do
return a

-- setFieldVisibility
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%. Sorry

Copy link
Contributor

@Kariel-Myrr Kariel-Myrr left a comment

Choose a reason for hiding this comment

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

We've added new cmd. Seems we have to add it to README

Problem: See issue #119.

Solution: Split `set-field` command into a `set-field` with contents
and `set-field-visibility`.
@sancho20021 sancho20021 force-pushed the sancho20021/#119-refactor-set-field-CLI branch from 01f4190 to 6bd6412 Compare August 2, 2022 17:23
@sancho20021
Copy link
Contributor Author

We've added new cmd. Seems we have to add it to README

True. Fixed. And also documentation about status codes

@sancho20021 sancho20021 mentioned this pull request Aug 2, 2022
5 tasks
@sancho20021 sancho20021 changed the title [#119] Refactor set-field in CLI [#119] Refactor set-field in CLI and WebAPI Aug 2, 2022
@sancho20021 sancho20021 requested a review from Kariel-Myrr August 2, 2022 17:29
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.

Refactor /set-field endpoint
2 participants