예제 #1
0
 /**
  * Query the users, restaurant, bookmarks, checkins, reviews
  *
  * @param $follower_id
  * @param int $restaurant_id
  * @return mixed
  */
 public static function getFollowedActivities($follower_id, $restaurant_id)
 {
     $following_ids = Follow::getFollowedUserIds($follower_id);
     $res_activities = self::whereIn('user_id', $following_ids)->orderBy('date_created', CONSTANTS::ORDER_DESC);
     if ($restaurant_id) {
         $res_activities->where('restaurant_id', $restaurant_id);
     }
     return $res_activities->paginate(CONSTANTS::RESTAURANTS_GET_ACTIVITIES_PAGINATION_LIMIT);
 }
예제 #2
0
 /**
  * Get list of users with the most number of activities
  * Prioritize users that are not being followed yet
  *
  * @param $user_id
  * @return Response
  */
 public function viewFeaturedUsersAction($user_id)
 {
     $followed_users = array();
     $featured_users = array();
     $json_return[KeyParser::data] = array();
     $users = Users::getUsersWithMostActivities()->toArray();
     $all_followed_users = Follow::getFollowedUserIds($user_id);
     foreach ($users as $user) {
         $is_followed = in_array($user['id'], $all_followed_users);
         if ($user['id'] != $user_id) {
             if ($is_followed) {
                 $followed_users[] = $user['id'];
             } else {
                 $featured_users[] = $user['id'];
             }
         }
     }
     $featured_users = array_merge($featured_users, $followed_users);
     $featured_users = array_slice($featured_users, 0, 20);
     foreach ($featured_users as $index => $featured_user) {
         $json_return[KeyParser::data][KeyParser::users][$index] = Users::getStatistics($featured_user, $user_id);
     }
     return response()->json($json_return);
 }