public function getZig() { $intervals = VKSearch::getZigDates(); $bDate = $this->bdate; if (!empty($bDate)) { $bDate = explode('.', $bDate); if (count($bDate) >= 2) { $day = (int) array_shift($bDate); $mounth = (int) array_shift($bDate); foreach ($intervals as $zig => $interval) { if (count($interval) >= 2) { $min = array_shift($interval); $max = array_shift($interval); if ($mounth == $min[1] || $mounth == $max[1]) { if ($day >= $min[0] || $day <= $max[0]) { return $zig; } } } } } } return -1; }
public function fastParse(VKUsers $forUser, $logger = false, $notLoadUsers = false) { if ($this->offset > 996) { return false; } $this->count++; $this->save(); $f = $this->filter; $inApi = []; $inPostProgress = []; \Log::info('MEM_3_1 ' . memory_get_usage()); $this->processFilters($inApi, $inPostProgress, $f); \Log::info('MEM_3_2 ' . memory_get_usage()); if (count($inApi) < 3 && $this->search_offset == 0) { // $this->search_offset = 800; } $inApi['offset'] = $this->search_offset; \Log::info('MEM_3_3 ' . memory_get_usage()); $searcher = new VKSearch($inApi, $inPostProgress, $this->user->access_token); \Log::info('MEM_3_4 ' . memory_get_usage()); $arUsers = $searcher->execute($countFetch, $logger); \Log::info('MEM_3_5 ' . memory_get_usage()); $arExist = DB::table('filter_user')->select('user_id')->where('filter_id', $this->id)->get(); $arExist = array_map(function ($item) { return $item->user_id; }, $arExist); $arNew = array_map(function ($item) { return $item->id; }, $arUsers); $diff = array_diff($arNew, $arExist); $diff = array_unique($diff); $diff = array_map(function ($item) { return ['user_id' => $item, 'filter_id' => $this->id]; }, $diff); DB::table('filter_user')->insert($diff); \Log::info('MEM_3_6 ' . memory_get_usage()); $this->search_offset += $countFetch; $this->save(); \Log::info('MEM_3_7 ' . memory_get_usage()); if ($notLoadUsers) { return []; } else { return $this->users()->whereNotIn('vk_users.id', $forUser->getPassedUserIds())->take(20)->get(); } }