<commit_before><?php

namespace Zhiyi\Plus\Http\Controllers\APIs\V2;

use DB;
use Illuminate\Http\Request;
use Zhiyi\Plus\Models\Like as LikeModel;
use Zhiyi\Plus\Models\Comment as CommentModel;
use Zhiyi\Plus\Support\PinnedsNotificationEventer;

class UserUnreadCountController extends Controller
{
    /**
     * 获取用户未读消息.
     *
     * @param Request $request
     * @param CommentModel $commentModel
     * @param LikeModel $likeModel
     * @return mixed
     * @author BS <<EMAIL>>
     */
    public function index(Request $request, CommentModel $commentModel, LikeModel $likeModel, PinnedsNotificationEventer $eventer)
    {
        $user = $request->user();
        $counts = $user->unreadCount;

        // 查询最近几条评论记录
        $comments = $commentModel->select('user_id', DB::raw('max(id) as id, max(created_at) as time'))
            ->where(function ($query) use ($user) {
                return $query->where('target_user', $user->id)
                    ->orWhere('reply_user', $user->id);
            })
            ->where('user_id', '!=', $user->id)
            ->limit(5)
            ->with('user')
            ->groupBy('user_id')
            ->orderBy('id', 'desc')
            ->get();

        // 查询最近几条点赞记录
        $likes = $likeModel->select('user_id', DB::raw('max(id) as id, max(created_at) as time'))
            ->where('target_user', $user->id)
            ->where('user_id', '!=', $user->id)
            ->limit(5)
            ->with('user')
            ->groupBy('user_id')
            ->orderBy('id', 'desc')
            ->get();

        // 未处理审核统计
        $pinneds = $eventer->dispatch()->mapWithKeys(function ($pinnedModels) use ($user) {
            $model = new $pinnedModels['namespace']();

            $pinneds[$pinnedModels['name']] = $model->where($pinnedModels['owner_prefix'], $user->id)->where($pinnedModels['audit_prefix'], $pinnedModels['unaudited_value'])->count();

            return $pinneds;
        });

        return response()->json([
            'counts' => $counts,
            'comments' => $comments,
            'likes' => $likes,
            'pinneds' => $pinneds,
        ], 200);
    }
}<commit_msg>更改未操作审核返回格式<commit_after><?php

namespace Zhiyi\Plus\Http\Controllers\APIs\V2;

use DB;
use Illuminate\Http\Request;
use Zhiyi\Plus\Models\Like as LikeModel;
use Zhiyi\Plus\Models\Comment as CommentModel;
use Zhiyi\Plus\Support\PinnedsNotificationEventer;

class UserUnreadCountController extends Controller
{
    /**
     * 获取用户未读消息.
     *
     * @param Request $request
     * @param CommentModel $commentModel
     * @param LikeModel $likeModel
     * @return mixed
     * @author BS <<EMAIL>>
     */
    public function index(Request $request, CommentModel $commentModel, LikeModel $likeModel, PinnedsNotificationEventer $eventer)
    {
        $user = $request->user();
        $counts = $user->unreadCount;

        // 查询最近几条评论记录
        $comments = $commentModel->select('user_id', DB::raw('max(id) as id, max(created_at) as time'))
            ->where(function ($query) use ($user) {
                return $query->where('target_user', $user->id)
                    ->orWhere('reply_user', $user->id);
            })
            ->where('user_id', '!=', $user->id)
            ->limit(5)
            ->with('user')
            ->groupBy('user_id')
            ->orderBy('id', 'desc')
            ->get();

        // 查询最近几条点赞记录
        $likes = $likeModel->select('user_id', DB::raw('max(id) as id, max(created_at) as time'))
            ->where('target_user', $user->id)
            ->where('user_id', '!=', $user->id)
            ->limit(5)
            ->with('user')
            ->groupBy('user_id')
            ->orderBy('id', 'desc')
            ->get();

        // 未处理审核统计
        $pinneds = $eventer->dispatch()->mapWithKeys(function ($pinnedModels) use ($user) {
            $model = new $pinnedModels['namespace']();

            $pinneds[$pinnedModels['name']] = $model->select(DB::raw('max(created_at) as time, count(*) as count'))->where($pinnedModels['owner_prefix'], $user->id)->where($pinnedModels['audit_prefix'], $pinnedModels['unaudited_value'])->first()->toArray();
            return $pinneds;
        });

        return response()->json([
            'counts' => $counts,
            'comments' => $comments,
            'likes' => $likes,
            'pinneds' => $pinneds,
        ], 200);
    }
}
{'fraction_non_alphanumeric': 0.17292377701934017, 'fraction_numerical': 0.0027303754266211604, 'mean_word_length': 2.292883895131086, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2649986', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1462, 'n_words': 247}