Rename discussion.commentsCount

This commit is contained in:
Toby Zerner 2018-08-24 20:37:04 +09:30
parent c3906eabcd
commit 5a6b0fc474
4 changed files with 8 additions and 8 deletions

View File

@ -18,8 +18,8 @@ Object.assign(Discussion.prototype, {
lastPost: Model.hasOne('lastPost'),
lastPostNumber: Model.attribute('lastPostNumber'),
commentsCount: Model.attribute('commentsCount'),
repliesCount: computed('commentsCount', commentsCount => Math.max(0, commentsCount - 1)),
commentCount: Model.attribute('commentCount'),
repliesCount: computed('commentCount', commentCount => Math.max(0, commentCount - 1)),
posts: Model.hasMany('posts'),
mostRelevantPost: Model.hasOne('mostRelevantPost'),

View File

@ -37,7 +37,7 @@ class DiscussionSerializer extends BasicDiscussionSerializer
$gate = $this->gate->forUser($this->actor);
$attributes = parent::getDefaultAttributes($discussion) + [
'commentsCount' => (int) $discussion->comment_count,
'commentCount' => (int) $discussion->comment_count,
'participantsCount' => (int) $discussion->participant_count,
'startTime' => $this->formatDate($discussion->created_at),
'lastTime' => $this->formatDate($discussion->last_posted_at),

View File

@ -230,11 +230,11 @@ class Discussion extends AbstractModel
}
/**
* Refresh the discussion's comments count.
* Refresh the discussion's comment count.
*
* @return $this
*/
public function refreshCommentsCount()
public function refreshCommentCount()
{
$this->comment_count = $this->comments()->count();

View File

@ -39,7 +39,7 @@ class DiscussionMetadataUpdater
$discussion = $event->post->discussion;
if ($discussion && $discussion->exists) {
$discussion->refreshCommentsCount();
$discussion->refreshCommentCount();
$discussion->refreshLastPost();
$discussion->refreshParticipantsCount();
$discussion->save();
@ -76,7 +76,7 @@ class DiscussionMetadataUpdater
$discussion = $event->post->discussion;
if ($discussion && $discussion->exists) {
$discussion->refreshCommentsCount();
$discussion->refreshCommentCount();
$discussion->refreshParticipantsCount();
$discussion->refreshLastPost();
$discussion->save();
@ -91,7 +91,7 @@ class DiscussionMetadataUpdater
$discussion = $post->discussion;
if ($discussion && $discussion->exists) {
$discussion->refreshCommentsCount();
$discussion->refreshCommentCount();
$discussion->refreshParticipantsCount();
if ($discussion->last_post_id == $post->id) {