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: Add caching to KnoraGroupRepo (DEV-3311) #3204

Merged
merged 7 commits into from
Apr 23, 2024

Conversation

seakayone
Copy link
Contributor

@seakayone seakayone commented Apr 22, 2024

  • refactor: Add caching to KnoraGroupRepo
  • Removes last remaining code in GroupsResponder updating a group, all group updates now go through the repo save mehtod

Pull Request Checklist

Task Description/Number

Issue Number: DEV-

PR Type

  • build/chore: maintenance tasks (no production code change)
  • docs: documentation changes (no production code change)
  • feat: represents new features
  • fix: represents bug fixes
  • perf: performance improvements
  • refactor: represents production code refactoring
  • test: adding or refactoring tests (no production code change)
  • deprecated: Deprecation warning (ideally referencing a migration guide)

Basic requirements for bug fixes and features

  • Tests for the changes have been added
  • Docs have been added / updated

Does this PR introduce a breaking change?

  • Yes

Does this PR change client-test-data?

  • Yes

@seakayone seakayone changed the title refactor/add caching to group repo refactor: Add caching to group repo Apr 22, 2024
@seakayone seakayone changed the title refactor: Add caching to group repo refactor: Add caching to KnoraGroupRepo Apr 22, 2024
@seakayone seakayone self-assigned this Apr 22, 2024
Remove last modfying functions from GroupResponder and make group repo extend CachingRepository
@seakayone seakayone changed the title refactor: Add caching to KnoraGroupRepo refactor: Add caching to KnoraGroupRepo (DEV-3311) Apr 22, 2024
Copy link

linear bot commented Apr 22, 2024

@seakayone seakayone marked this pull request as ready for review April 22, 2024 15:19
Copy link
Contributor

@BalduinLandolt BalduinLandolt left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Comment on lines 81 to 86
groupAndProject <- auth.ensureSystemAdminOrProjectAdminOfGroup(user, iri)
(group, _) = groupAndProject
internal <- knoraGroupService
.updateGroupStatus(group, request.status)
.flatMap(groupService.toGroup)
.map(GroupGetResponseADM.apply)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: not sure if it makes sense to have for-comprehensions if we use map and flatmap in them; or vice versa, if it makes sense to use map and flatmap, if we're in a for-comprehension

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this still reads better than chaining it all in one go. These lines could be also extracted to separate private methods, especially they are reused in deleteGroup methods below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I am totally ok to mix for comprehension with a flatmap here and there,
  2. I am totally ok with a chain of flatmaps here and there
  3. I had my reason of why the internal has become its own name and the intermediate transformative results where in a chain of map/flatMap for my personal preference of making it clear that toGroup and Foo.apply are simply transformations of intermediate unimportant results.
  4. I have extracted the code duplication in a separate method and introduced intermediate result name due to popular demand. b247906

TBH, I find this kind of discussion exhausting and have a different preference for readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

It does look better with the flatMap refactored.

Copy link
Contributor

@mpro7 mpro7 left a comment

Choose a reason for hiding this comment

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

Thanks. Please find my minor suggestions below:

Comment on lines 81 to 86
groupAndProject <- auth.ensureSystemAdminOrProjectAdminOfGroup(user, iri)
(group, _) = groupAndProject
internal <- knoraGroupService
.updateGroupStatus(group, request.status)
.flatMap(groupService.toGroup)
.map(GroupGetResponseADM.apply)
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this still reads better than chaining it all in one go. These lines could be also extracted to separate private methods, especially they are reused in deleteGroup methods below.

@seakayone seakayone enabled auto-merge (squash) April 23, 2024 06:45
@seakayone seakayone disabled auto-merge April 23, 2024 06:47
@seakayone seakayone enabled auto-merge (squash) April 23, 2024 06:57
@seakayone seakayone merged commit 57a3a06 into main Apr 23, 2024
11 checks passed
@seakayone seakayone deleted the refactor/add-caching-to-group-repo branch April 23, 2024 07:07
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.

4 participants