Rename user posts count to comments count

This commit is contained in:
Toby Zerner 2015-03-12 10:34:59 +10:30
parent 64b6698791
commit 2882ecd46e
3 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ class CreateUsersTable extends Migration {
$table->dateTime('last_seen_time')->nullable();
$table->dateTime('read_time')->nullable();
$table->integer('discussions_count')->unsigned()->default(0);
$table->integer('posts_count')->unsigned()->default(0);
$table->integer('comments_count')->unsigned()->default(0);
});
}

View File

@ -33,7 +33,7 @@ class UserSerializer extends UserBasicSerializer
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
'discussionsCount' => (int) $user->discussions_count,
'postsCount' => (int) $user->posts_count,
'commentsCount' => (int) $user->comments_count,
'canEdit' => $canEdit,
'canDelete' => $user->can($actorUser, 'delete'),
];

View File

@ -131,7 +131,7 @@ class DiscussionsTableSeeder extends Seeder
$prefix = DB::getTablePrefix();
DB::table('users')->update([
'discussions_count' => DB::raw('(SELECT COUNT(id) FROM '.$prefix.'discussions WHERE start_user_id = '.$prefix.'users.id)'),
'posts_count' => DB::raw('(SELECT COUNT(id) FROM '.$prefix.'posts WHERE user_id = '.$prefix.'users.id and type = "comment")'),
'comments_count' => DB::raw('(SELECT COUNT(id) FROM '.$prefix.'posts WHERE user_id = '.$prefix.'users.id and type = "comment")'),
]);
}
}