コード例 #1
0
ファイル: User.php プロジェクト: stels-cs/tinder-olega
 public function getDislike(Request $r)
 {
     try {
         $uid = $r->get('id', false);
         $filterId = $r->get('filter_id', false);
         if ($uid) {
             $mid = $this->getUser()->id;
             if ($filterId) {
                 $filter = VKFilter::find($filterId);
             }
             $exits = DB::table('vk_like')->where('from_id', $mid)->where('to_id', $uid)->count();
             if ($exits) {
                 return response()->json(['id' => trans('main.already-like'), 'filter' => !empty($filter) ? $filter->getList($this->getUser()) : []], 422);
             } else {
                 DB::table('vk_like')->insert(['from_id' => $mid, 'to_id' => $uid, 'type' => 0]);
                 return response()->json(['ok' => 'ok', 'filter' => !empty($filter) ? $filter->getList($this->getUser()) : []]);
             }
         } else {
             return response()->json(['id' => trans('main.id-not-pass')]);
         }
     } catch (\Exception $e) {
         \Log::error($e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine());
         return $e->getMessage() . ' file ' . $e->getFile() . ':' . $e->getLine();
     }
 }
コード例 #2
0
ファイル: Filter.php プロジェクト: stels-cs/tinder-olega
 public function store(\Illuminate\Http\Request $r)
 {
     try {
         $filter = $r->get('filter', []);
         if (!empty($filter)) {
             $hash = VKFilter::createHash($filter);
             $_filter = VKFilter::where('hash', $hash)->where('user_id', $this->getUser()->id)->first();
             if (empty($_filter)) {
                 $_filter = VKFilter::create(['filter' => $filter, 'user_id' => $this->getUser()->id]);
                 $data = $_filter->fastParse($this->getUser());
                 $this->startFetchingFilter($_filter);
                 if ($data->count() < 2) {
                     $_filter->attachFromLoad(false, true);
                     $data = $filter->getList();
                 }
                 return response()->json(['filter' => $_filter, 'feed' => $data]);
             } else {
                 return response()->json(['filter' => $_filter, 'feed' => $_filter->getList($this->getUser())]);
             }
         } else {
             return response()->json(['filter' => trans('main.filter-empty')], 400);
         }
     } catch (\Exception $e) {
         \Log::error($e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine());
         return $e->getMessage() . ' file ' . $e->getFile() . ':' . $e->getLine();
     }
 }
コード例 #3
0
ファイル: Info.php プロジェクト: stels-cs/tinder-olega
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $u = $this->argument('u');
     $okCount = VKUsers::where('fake', false)->count();
     $this->info('good akk in db = ' . $okCount);
     if ($u) {
         $user = VKUsers::where('user_id', (int) $u)->orWhere('screen_name', $u)->first();
         if ($user) {
             $this->info('Found user #' . $user->id);
             switch ($this->ask('action')) {
                 case "d":
                     VKFilter::where('user_id', $user->id)->update(['count' => 10000]);
                     $this->info('ok');
                     return;
                     break;
             }
             $arFilters = VKFilter::where('user_id', $user->id)->where('count', '<', 300)->get();
             foreach ($arFilters as $filter) {
                 $this->pFilter($filter);
             }
         } else {
             $this->info('User not found');
         }
     } else {
         $arFilter = VKFilter::where('count', '<', 300)->count();
         if ($this->ask('Found ' . $arFilter . ' show all?') == 'y') {
             foreach (VKFilter::where('count', '<', 300)->get() as $filter) {
                 $this->pFilter($filter);
             }
         }
     }
 }
コード例 #4
0
ファイル: FetchFilter.php プロジェクト: stels-cs/tinder-olega
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (empty($this->id)) {
         $id = $this->argument('id');
     } else {
         $id = $this->id;
     }
     $this->_l('Filter start #' . $id, true);
     \Log::info('MEM_1 ' . memory_get_usage());
     $filter = VKFilter::find($id);
     \Log::info('MEM_2 ' . memory_get_usage());
     $restart = false;
     if ($filter) {
         $this->_l('Found filter #' . $id);
         /**
          * @var VKFilter $filter
          */
         \Log::info('MEM_3 ' . memory_get_usage());
         $res = $filter->fastParse($filter->user, $this, true);
         \Log::info('MEM_4 ' . memory_get_usage());
         if ($res !== false) {
             if ($filter->fetch_offset < 996 && $filter->count < 300) {
                 $restart = $filter->id;
                 $this->_l('Load ok search_offset = ' . $filter->search_offset . ' users for filter #' . $filter->id, true);
             } else {
                 $this->_l('End fetching for filter #' . $filter->id, true);
             }
         } else {
             $this->_l("End working for filter #" . $filter->id, true);
         }
     } else {
         $this->_l("Filter #" . $id . ' not found');
     }
     if ($restart) {
         $this->restartFilter($restart);
     }
     \Log::info('MEM_5 ' . memory_get_usage());
     return true;
 }