diff --git a/framework/core/ember/app/helpers/abbreviate-time.js b/framework/core/ember/app/helpers/human-time.js similarity index 82% rename from framework/core/ember/app/helpers/abbreviate-time.js rename to framework/core/ember/app/helpers/human-time.js index 2e916e6fd..300886f54 100644 --- a/framework/core/ember/app/helpers/abbreviate-time.js +++ b/framework/core/ember/app/helpers/human-time.js @@ -15,11 +15,11 @@ export default Ember.Handlebars.makeBoundHelper(function(time) { var diff = Math.abs(m.diff(moment())); if (diff < 60 * minute) { - ago = moment.duration(diff).minutes()+'m'; + ago = moment.duration(diff).minutes()+'m ago'; } else if (diff < 24 * hour) { - ago = moment.duration(diff).hours()+'h'; + ago = moment.duration(diff).hours()+'h ago'; } else if (diff < 30 * day) { - ago = moment.duration(diff).days()+'d'; + ago = moment.duration(diff).days()+'d ago'; } else if (m.year() == moment().year()) { ago = m.format('D MMM'); } else { diff --git a/framework/core/ember/app/models/discussion.js b/framework/core/ember/app/models/discussion.js index cff307ef8..455bd510e 100644 --- a/framework/core/ember/app/models/discussion.js +++ b/framework/core/ember/app/models/discussion.js @@ -24,10 +24,10 @@ var Discussion = DS.Model.extend({ relevantPosts: DS.hasMany('post'), - postsCount: DS.attr('number'), + commentsCount: DS.attr('number'), repliesCount: function() { - return Math.max(0, this.get('postsCount') - 1); - }.property('postsCount'), + return Math.max(0, this.get('commentsCount') - 1); + }.property('commentsCount'), posts: DS.attr('string'), postIds: function() { diff --git a/framework/core/src/Flarum/Api/Serializers/DiscussionSerializer.php b/framework/core/src/Flarum/Api/Serializers/DiscussionSerializer.php index 208056299..67032adde 100644 --- a/framework/core/src/Flarum/Api/Serializers/DiscussionSerializer.php +++ b/framework/core/src/Flarum/Api/Serializers/DiscussionSerializer.php @@ -28,7 +28,7 @@ class DiscussionSerializer extends DiscussionBasicSerializer $attributes = parent::attributes($discussion); $attributes += [ - 'postsCount' => (int) $discussion->posts_count, + 'commentsCount' => (int) $discussion->comments_count, 'startTime' => $discussion->start_time->toRFC3339String(), 'lastTime' => $discussion->last_time ? $discussion->last_time->toRFC3339String() : null, 'lastPostNumber' => $discussion->last_post_number, diff --git a/framework/core/src/Flarum/Core/Discussions/Discussion.php b/framework/core/src/Flarum/Core/Discussions/Discussion.php index 1cc279905..8c17bd1c9 100755 --- a/framework/core/src/Flarum/Core/Discussions/Discussion.php +++ b/framework/core/src/Flarum/Core/Discussions/Discussion.php @@ -19,7 +19,7 @@ class Discussion extends Entity protected static $rules = [ 'title' => 'required', 'start_time' => 'required|date', - 'posts_count' => 'integer', + 'comments_count' => 'integer', 'start_user_id' => 'integer', 'start_post_id' => 'integer', 'last_time' => 'date', @@ -79,13 +79,13 @@ class Discussion extends Entity public function refreshLastPost() { - $lastPost = $this->dialog()->orderBy('time', 'desc')->first(); + $lastPost = $this->comments()->orderBy('time', 'desc')->first(); $this->setLastPost($lastPost); } - public function refreshPostsCount() + public function refreshCommentsCount() { - $this->posts_count = $this->dialog()->count(); + $this->comments_count = $this->comments()->count(); } public function rename($title, $user) @@ -109,7 +109,7 @@ class Discussion extends Entity return $this->hasMany('Flarum\Core\Posts\Post')->orderBy('time', 'asc'); } - public function dialog() + public function comments() { return $this->posts()->where('type', 'comment')->whereNull('delete_time'); } diff --git a/framework/core/src/Flarum/Core/Discussions/DiscussionFinder.php b/framework/core/src/Flarum/Core/Discussions/DiscussionFinder.php index 0efabbf54..44b525fb5 100644 --- a/framework/core/src/Flarum/Core/Discussions/DiscussionFinder.php +++ b/framework/core/src/Flarum/Core/Discussions/DiscussionFinder.php @@ -16,7 +16,7 @@ class DiscussionFinder protected $sortMap = [ 'lastPost' => ['last_time', 'desc'], - 'replies' => ['posts_count', 'desc'], + 'replies' => ['comments_count', 'desc'], 'created' => ['start_time', 'desc'] ]; diff --git a/framework/core/src/Flarum/Core/Support/Seeders/DiscussionTableSeeder.php b/framework/core/src/Flarum/Core/Support/Seeders/DiscussionTableSeeder.php index cabbb1a9b..9eecdf502 100644 --- a/framework/core/src/Flarum/Core/Support/Seeders/DiscussionTableSeeder.php +++ b/framework/core/src/Flarum/Core/Support/Seeders/DiscussionTableSeeder.php @@ -29,7 +29,7 @@ class DiscussionTableSeeder extends Seeder 'start_time' => $faker->dateTimeThisYear, 'start_user_id' => rand(1, $users) ]); - $discussion->posts_count = $posts_count; + $discussion->comments_count = $posts_count; $post = Post::create([ 'discussion_id' => $discussion->id, @@ -57,7 +57,7 @@ class DiscussionTableSeeder extends Seeder for ($j = 0; $j < $count - 1; $j++) { if (rand(1, 100) == 1) { - $discussion->posts_count--; + $discussion->comments_count--; $post = Post::create([ 'discussion_id' => $discussion->id, @@ -71,7 +71,7 @@ class DiscussionTableSeeder extends Seeder $deleted = rand(1, 100) == 1; if ($deleted) { - $discussion->posts_count--; + $discussion->comments_count--; } $post = Post::create([ diff --git a/framework/core/src/migrations/2014_01_14_231321_create_discussions_table.php b/framework/core/src/migrations/2014_01_14_231321_create_discussions_table.php index e842e98c3..beec9027b 100644 --- a/framework/core/src/migrations/2014_01_14_231321_create_discussions_table.php +++ b/framework/core/src/migrations/2014_01_14_231321_create_discussions_table.php @@ -18,7 +18,7 @@ class CreateDiscussionsTable extends Migration { $table->increments('id'); $table->string('title'); - $table->integer('posts_count')->unsigned()->default(0); + $table->integer('comments_count')->unsigned()->default(0); $table->integer('number_index')->unsigned()->default(0); $table->dateTime('start_time');