Skip to content

Remove unneeded if statements for update repo API #35140

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

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

Conversation

6543
Copy link
Member

@6543 6543 commented Jul 21, 2025

just try to make the update func more redable and be more KISS


Sponsored by Kithara Software GmbH

@6543 6543 added type/refactoring Existing code has been cleaned up. There should be no new functionality. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Jul 21, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 21, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Jul 21, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 21, 2025
@delvh delvh changed the title Refactor: make if statements more redable and have less checks as not needed Refactor: Remove unneeded if statements Jul 21, 2025
@delvh delvh changed the title Refactor: Remove unneeded if statements Remove unneeded if statements for update repo API Jul 21, 2025
@6543
Copy link
Member Author

6543 commented Jul 21, 2025

TestAPIRepoEdit fails but i dont know why jet

@lunny
Copy link
Member

lunny commented Jul 21, 2025

It's related. The logic is different from previous implementation. All UnitEnabled missed.

@6543
Copy link
Member Author

6543 commented Jul 21, 2025

of course it was related ... see fix

and the check if unit exists is not needed and was already missing in some unit update codeblocks ...

@6543
Copy link
Member Author

6543 commented Jul 21, 2025

  • in case a unit does not exist and is going to be marked as deleted -> db query will just ignore it as there is no match
  • in case a unit does exist and is going to be marked as deleted -> db query will match and delete it
  • in case a unit dose exist and the option defines a new one, before the new values are set the unit gets deteted and recreated with the new settings -> no check needed if it exist because it will be deleted before if so
  • in case a unit dose not exist and the option defines a new one, it gets created with the new settings -> no check needed

@6543
Copy link
Member Author

6543 commented Jul 21, 2025

was an logic issue ... where two excluse unit tyes exist and there globalEnabled check was if-else-if chained ...

@6543 6543 requested a review from lunny July 21, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants