profileId = $profileId; } /** * Execute the job. * * @return void */ public function handle() { $id = $this->profileId; $account = AccountService::get($id, true); if(!$account) { Cache::put(FollowerService::FOLLOWERS_SYNC_KEY . $id, 1, 604800); Cache::put(FollowerService::FOLLOWING_SYNC_KEY . $id, 1, 604800); return; } DB::table('followers') ->select('id', 'following_id', 'profile_id') ->whereFollowingId($id) ->orderBy('id') ->chunk(200, function($followers) use($id) { foreach($followers as $follow) { FollowerService::add($follow->profile_id, $id); } }); DB::table('followers') ->select('id', 'following_id', 'profile_id') ->whereProfileId($id) ->orderBy('id') ->chunk(200, function($followers) use($id) { foreach($followers as $follow) { FollowerService::add($id, $follow->following_id); } }); Cache::put(FollowerService::FOLLOWERS_SYNC_KEY . $id, 1, 604800); Cache::put(FollowerService::FOLLOWING_SYNC_KEY . $id, 1, 604800); $profile = Profile::find($id); if($profile) { $profile->following_count = DB::table('followers')->whereProfileId($id)->count(); $profile->followers_count = DB::table('followers')->whereFollowingId($id)->count(); $profile->save(); } AccountService::del($id); return; } }