Skip to content

Commit

Permalink
Update score and ranking on updates and on create
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich committed Jun 26, 2024
1 parent 393646e commit 2b3d785
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Service/EntryCommentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function create(EntryCommentDto $dto, User $user, $rateLimit = true): Ent

$comment->entry->addComment($comment);

$comment->updateScore();
$comment->updateRanking();

$this->entityManager->persist($comment);
$this->entityManager->flush();

Expand Down Expand Up @@ -123,6 +126,8 @@ public function edit(EntryComment $comment, EntryCommentDto $dto): EntryComment
$comment->apLikeCount = $dto->apLikeCount;
$comment->apDislikeCount = $dto->apDislikeCount;
$comment->apShareCount = $dto->apShareCount;
$comment->updateScore();
$comment->updateRanking();

$this->entityManager->flush();

Expand Down
5 changes: 5 additions & 0 deletions src/Service/EntryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public function create(EntryDto $dto, User $user, bool $rateLimit = true): Entry
$this->badgeManager->assign($entry, $dto->badges);
}

$entry->updateScore();
$entry->updateRanking();

$this->entityManager->persist($entry);
$this->entityManager->flush();

Expand Down Expand Up @@ -183,6 +186,8 @@ public function edit(Entry $entry, EntryDto $dto): Entry
$entry->apLikeCount = $dto->apLikeCount;
$entry->apDislikeCount = $dto->apDislikeCount;
$entry->apShareCount = $dto->apShareCount;
$entry->updateScore();
$entry->updateRanking();

$this->entityManager->flush();

Expand Down
4 changes: 4 additions & 0 deletions src/Service/PostCommentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function create(PostCommentDto $dto, User $user, $rateLimit = true): Post
}

$comment->post->addComment($comment);
$comment->updateScore();
$comment->updateRanking();

$this->entityManager->persist($comment);
$this->entityManager->flush();
Expand Down Expand Up @@ -132,6 +134,8 @@ public function edit(PostComment $comment, PostCommentDto $dto): PostComment
$comment->apLikeCount = $dto->apLikeCount;
$comment->apDislikeCount = $dto->apDislikeCount;
$comment->apShareCount = $dto->apShareCount;
$comment->updateScore();
$comment->updateRanking();

$this->entityManager->flush();

Expand Down
5 changes: 5 additions & 0 deletions src/Service/PostManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function create(PostDto $dto, User $user, $rateLimit = true): Post
throw new \Exception('Post body and image cannot be empty');
}

$post->updateScore();
$post->updateRanking();

$this->entityManager->persist($post);
$this->entityManager->flush();

Expand Down Expand Up @@ -135,6 +138,8 @@ public function edit(Post $post, PostDto $dto): Post
$post->apLikeCount = $dto->apLikeCount;
$post->apDislikeCount = $dto->apDislikeCount;
$post->apShareCount = $dto->apShareCount;
$post->updateScore();
$post->updateRanking();

$this->entityManager->flush();

Expand Down

0 comments on commit 2b3d785

Please sign in to comment.