From 5a6b0fc474c1bb820e94228b2a3e469be50d51f2 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 24 Aug 2018 20:37:04 +0930 Subject: [PATCH] Rename discussion.commentsCount --- framework/core/js/src/common/models/Discussion.js | 4 ++-- framework/core/src/Api/Serializer/DiscussionSerializer.php | 2 +- framework/core/src/Discussion/Discussion.php | 4 ++-- framework/core/src/Discussion/DiscussionMetadataUpdater.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/core/js/src/common/models/Discussion.js b/framework/core/js/src/common/models/Discussion.js index ab6664df7..e57eafab9 100644 --- a/framework/core/js/src/common/models/Discussion.js +++ b/framework/core/js/src/common/models/Discussion.js @@ -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'), diff --git a/framework/core/src/Api/Serializer/DiscussionSerializer.php b/framework/core/src/Api/Serializer/DiscussionSerializer.php index e99d5522b..e8f3df822 100644 --- a/framework/core/src/Api/Serializer/DiscussionSerializer.php +++ b/framework/core/src/Api/Serializer/DiscussionSerializer.php @@ -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), diff --git a/framework/core/src/Discussion/Discussion.php b/framework/core/src/Discussion/Discussion.php index e11ff17c5..cce9f1aa1 100644 --- a/framework/core/src/Discussion/Discussion.php +++ b/framework/core/src/Discussion/Discussion.php @@ -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(); diff --git a/framework/core/src/Discussion/DiscussionMetadataUpdater.php b/framework/core/src/Discussion/DiscussionMetadataUpdater.php index b1f894f4c..cb89a40c7 100644 --- a/framework/core/src/Discussion/DiscussionMetadataUpdater.php +++ b/framework/core/src/Discussion/DiscussionMetadataUpdater.php @@ -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) {