Skip to content

Commit

Permalink
improve generator
Browse files Browse the repository at this point in the history
  • Loading branch information
s39f4lt committed Jan 5, 2021
1 parent 1c6bf44 commit 3087ee8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions generator/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,25 @@ public static void main(String[] args) {
private static void createOtherData(List<User> users) {
users.forEach(user -> {
String jwt = authorize(user.getUsername(), user.getPassword());
Set<Integer> likeSet = new HashSet<>();
for (int likeCount = 0; likeCount < 15; likeCount++) {
int randomLike = random(users.size() - 1, 0);
createLike(user.getId(), randomLike, jwt);
likeSet.add(randomLike);
}
likeSet.forEach(like -> createLike(user.getId(), like, jwt));

for (int guestCount = 0; guestCount < 15; guestCount++) {
int randomGuest = random(users.size() - 1, 0);
createGuest(user.getId(), randomGuest, jwt);
}

List<String> tags = getFile(HASHTAGS);
Set<String> tagSet = new HashSet<>();
for (int tagCount = 0; tagCount < 5; tagCount++) {
String tag = tags.get(random(tags.size() - 1, 0));
createTag(user.getId(), tag, jwt);
tagSet.add(tag);
}
tagSet.forEach(tag -> createTag(user.getId(), tag, jwt));
});
}

Expand Down Expand Up @@ -116,7 +122,13 @@ private static void createTag(Long id, String tag, String jwt) {
}

private static void distributionImages(List<User> users, List<Image> images) {
users.forEach(user -> user.setImage(images.stream().filter(image -> image.getUserId().equals(user.getId())).findFirst().get()));
users.forEach(user -> user.setImage(images
.stream()
.filter(image -> image.getUserId().equals(user.getId()))
.findFirst()
.get()
)
);
}

private static List<Image> deserializeListImages(String json) {
Expand Down

0 comments on commit 3087ee8

Please sign in to comment.