Skip to content

Persistence of shares implemented(not yet a full version) #219

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

basicaleksa1
Copy link
Collaborator

This is just the wip for a general structure for jdbc persistence, if this is alright I'll model all the entities that are required for persistence then make a big PR

@basicaleksa1 basicaleksa1 self-assigned this Feb 5, 2024
Copy link
Collaborator

@agilelab-tmnd1991 agilelab-tmnd1991 left a comment

Choose a reason for hiding this comment

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

One additional comment, how do we decide which storage implementation is used between the memory and postgres one?

Comment on lines +18 to +24
@Inject
ShareRepository shareRepository;

@Inject
public JdbcStorageManager(){
this.shareRepository = new ShareRepository();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use constructor based injection, also have a look at:
https://agile-lab-dev.github.io/whitefox/docs/development_guidelines

Comment on lines +34 to +45
List<Share> shares = shareRepository.listAll().stream()
.map(ShareMapper::shareDaoToShare)
.collect(Collectors.toList());
var totalSize = shares.size();
if (offset > totalSize) {
throw new InvalidPageTokenException(
String.format("Invalid Next Page Token: token %s is larger than totalSize", offset));
} else {
return new ResultAndTotalSize<>(
shares.stream().skip(offset).limit(maxResultSize).collect(Collectors.toList()),
totalSize);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This eagerly fetches all shares, it might get very slow when a lot of shares are created.
Have a look at: https://quarkus.io/guides/hibernate-orm-panache#paging

import java.util.Optional;
@Entity
@Table(name = "share")
public class ShareDao {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you can/want you can use Lombok to auto-generate some boilerplate

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.

3 participants