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

Refactor library folder API logic into FoldersService #11631

Merged
merged 6 commits into from Apr 7, 2021

Conversation

davelopez
Copy link
Contributor

What did you do?

  • Add basic API tests for the library folders API.
  • Removed unused mixins (UsesLibraryMixin, UsesLibraryMixinItems) from FoldersController.
  • Move the FoldersController logic into the FoldersManager class to be reused by the future FastAPI controller.

Why did you make this change?

This will simplify the migration to FastAPI of this route in a future PR as well as provide some automated tests as a harness.

How to test the changes?

@github-actions github-actions bot added this to the 21.05 milestone Mar 16, 2021
@davelopez davelopez added the kind/refactoring cleanup or refactoring of existing code, no functional changes label Mar 16, 2021
@@ -309,3 +312,257 @@ def cut_and_decode(self, trans, encoded_folder_id):
:rtype: int
"""
return self.decode_folder_id(trans, self.cut_the_prefix(encoded_folder_id))


class FoldersManager:
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between the FolderManager and FoldersManager? Should these be the same class?

Copy link
Contributor Author

@davelopez davelopez Mar 16, 2021

Choose a reason for hiding this comment

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

The s character... just kidding 😆

The idea is that FoldersManager encapsulates the logic for the FoldersController and uses FolderManager and RoleManager to implement it. This class will also use and return the future pydantic models.
But yeah... I agree the name is not the best... 😅

Do you think these two should go together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmchilton
Do you prefer this approach to deal with the class encapsulating the controller logic instead of calling it a Manager? Or am I going completely offroad here? 😆

Appreciated any advice on how to proceed with this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have renamed the FoldersManager to FoldersService to better differentiate the class encapsulating the API actions logic from the regular Managers used to deal with the database models.
I have also used this naming in #11712 to unify it a bit. Again, the idea is to have this layer that directly speaks "pydantic" and uses the appropriate managers under the hood to expose the API actions that can be then called from the API controllers (either legacy or FastAPI) in a one-liner to reuse as much logic as possible and keed the API controllers thin.

But I am really open to better naming ideas or changes in this approach :)

@davelopez davelopez changed the title Refactor library folder API logic into FoldersManager Refactor library folder API logic into FoldersService Mar 29, 2021
@jmchilton jmchilton merged commit 0784f80 into galaxyproject:dev Apr 7, 2021
@jmchilton
Copy link
Member

Awesome - thanks so much! I'm fine with the new naming convention of managers vs services - makes a lot of sense.

@davelopez davelopez deleted the refactor_library_folder_api branch April 7, 2021 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/API area/testing/api area/testing kind/refactoring cleanup or refactoring of existing code, no functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants