Ejemplo n.º 1
0
 public function getUserCount(Request $request)
 {
     // add validator
     $query = $request->input('query');
     if (!$query) {
         $query = $request->input('queryFirst');
     }
     $date = $request->input('date');
     $rangeFromRequest = $request->input('range');
     $range = $rangeFromRequest ? $rangeFromRequest : floor(config('controls.countReportRange') / 2);
     if ($range == 1) {
         $dateStart = $dateEnd = strtotime($date);
     } else {
         $range /= 2;
         $range = floor($range);
         $dateStart = strtotime('-' . $range . ' days', strtotime($date));
         $dateEnd = strtotime('+' . $range . ' days', strtotime($date));
     }
     $twit = new Twitter($query, $date);
     $lat = $request->input('lat');
     $lng = $request->input('lng');
     $venues = new BusyVenues($lat, $lng, $date, null);
     $returnData = array($query => array('twitter' => $twit->getCountForRange($dateStart, $dateEnd), 'venues' => $venues->getCountForRange($dateStart, $dateEnd)));
     return json_encode($returnData);
 }
Ejemplo n.º 2
0
 public function getResults(Request $request)
 {
     $validator = Validator::make($request->all(), $this->rules());
     if ($validator->fails()) {
         return redirect()->route('event')->withErrors($validator)->withInput();
     }
     $query = $request->input('query' . $this->firstID);
     $date = $request->input('date');
     if (!$query) {
         return redirect()->route('event');
     }
     $twit = new Twitter($query);
     $lat = $request->input('lat');
     $lng = $request->input('lng');
     $venues = new BusyVenues($lat, $lng);
     $firstElement = array('id' => $this->firstID);
     /**
      * sorting the array
      */
     $mergeQueries = array_merge($twit->getData(strtotime($date), 0, 10), $venues->getData(strtotime($date), 0, 20));
     usort($mergeQueries, array($this, 'date_compare'));
     $response = array('elements' => array('first' => $firstElement), 'response' => $mergeQueries);
     return view('search.result')->with('data', $response)->withInput($request->all());
 }
Ejemplo n.º 3
0
 public function getResultsForEvent($query, Request $request)
 {
     $cacheTag = 'fullResponse';
     //config timeline twitter
     $cacheKey = '';
     $cacheLimit = 15;
     $requestParameters = array_values($request->all());
     array_pop($requestParameters);
     foreach ($requestParameters as $value) {
         $cacheKey .= $value;
     }
     /**
      *      UNCOMMENT IF USING INFINITE SCROLLING IN THE COMPARISON VIEW
      */
     //        foreach ($requestParameters as $value) {
     //            if ($this->isFirst($query, $request)) {
     //                if ($value !== $request->input("querySecond")) {
     //                    $cacheKey .= $value;
     //                }
     //            } else {
     //                if ($value !== $request->input("queryFirst")) {
     //                    $cacheKey .= $value;
     //                }
     //            }
     //        }
     //        if (Cache::has($cacheKey)) {
     //            return Cache::get($cacheKey);
     //        }
     $date = $request->input('date');
     $query = $query ? $query : $request->input('twitterAccount');
     $twitterAccount = $request->input('twitterAccount');
     $twitTimeline = $twitterAccount ? new TwitterTimeline($twitterAccount, $date) : new TwitterTimeline($query, $date);
     $twit = new Twitter($query, $date);
     $lat = $request->input('lat');
     $lng = $request->input('lng');
     /**
      *      UNCOMMENT IF DELAYED SERVICES API WORKS
      */
     //        $trainStations = new TrainStations($lat, $lng, $date);
     //        $stations = $trainStations->getData();
     //        // if there are any train stations nearby
     //        if (count($stations) > 0) {
     //            $delayedService = new DelayedServices($date);
     //            foreach ($stations as $station) {
     //                $delayedService->getDate($station['tiploc']);
     //            }
     //        }
     // */
     $venues = new BusyVenues($lat, $lng, $date, null);
     /**
      * sorting the array
      */
     $searchToken = $request->input('searchToken');
     $mergeQueries = array_merge((array) $twit->getData(), $searchToken && $searchToken === 'venue' ? (array) $venues->getVenueData(strtotime($date)) : (array) $venues->getData(), (array) $twitTimeline->getData());
     usort($mergeQueries, array($this, 'date_compare'));
     $response = array('sections' => array(), 'info' => array());
     /* getting sections */
     $response['sections'] = $this->generateSections($mergeQueries);
     $twitterInfo = $twit->getInfo();
     if (count($twitterInfo) > 0) {
         $response['info']['twitter'] = $twitterInfo;
     }
     if (count($response['sections']) > 0 && $request->input('querySecond') == null) {
         //&& !is_null(Cache::get($cacheKey))) {
         Cache::put($cacheKey, $response, $cacheLimit);
     }
     return $response;
 }