Ejemplo n.º 1
0
 public static function processLocations()
 {
     $sublets = self::$coll->find();
     $cityStateCounts = [];
     foreach ($sublets as $sublet) {
         if (empty($sublet['address']) || empty($sublet['city']) || empty($sublet['state'])) {
             continue;
         }
         $address = $sublet['address'];
         $city = $sublet['city'];
         $state = $sublet['state'];
         $location = "{$address}, {$city}, {$state}";
         $geocode = GeocodeModel::get($location);
         if (is_null($geocode)) {
             continue;
         }
         $cityState = strtolower(getCityStateFromGeocode($geocode));
         if (isset($cityStateCounts[$cityState])) {
             $cityStateCounts[$cityState]++;
         } else {
             $cityStateCounts[$cityState] = 1;
         }
     }
     arsort($cityStateCounts);
     return $cityStateCounts;
 }
Ejemplo n.º 2
0
 public static function processLocations()
 {
     $jobs = self::$coll->find();
     $cityStateCounts = [];
     foreach ($jobs as $job) {
         if (empty($job['location'])) {
             continue;
         }
         $location = $job['location'];
         $geocode = GeocodeModel::get($location);
         if (is_null($geocode)) {
             continue;
         }
         $cityState = strtolower(getCityStateFromGeocode($geocode));
         if (isset($cityStateCounts[$cityState])) {
             $cityStateCounts[$cityState]++;
         } else {
             $cityStateCounts[$cityState] = 1;
         }
     }
     arsort($cityStateCounts);
     return $cityStateCounts;
 }
Ejemplo n.º 3
0
 public static function processByStudent($email)
 {
     $subletLocations = [];
     $jobLocations = [];
     $jobIndustries = [];
     foreach (self::$searches as $time => $search) {
         if (!is_array($search)) {
             continue;
         }
         if ($search['email'] != $email) {
             continue;
         }
         switch ($search['type']) {
             case 'sublets':
                 if (!empty($search['data']['location'])) {
                     $location = strtolower($search['data']['location']);
                     // Location to geocode, to City, State.
                     $geocode = GeocodeModel::get($location);
                     if (is_null($geocode)) {
                         continue;
                     }
                     $cityState = strtolower(getCityStateFromGeocode($geocode));
                     if (isset($subletLocations[$cityState])) {
                         $subletLocations[$cityState]++;
                     } else {
                         $subletLocations[$cityState] = 1;
                     }
                 }
                 break;
             case 'jobs':
                 if (!empty($search['data']['city'])) {
                     $location = strtolower($search['data']['city']);
                     // Location to geocode, to City, State.
                     $geocode = GeocodeModel::get($location);
                     if (is_null($geocode)) {
                         continue;
                     }
                     $cityState = strtolower(getCityStateFromGeocode($geocode));
                     if (isset($jobLocations[$cityState])) {
                         $jobLocations[$cityState]++;
                     } else {
                         $jobLocations[$cityState] = 1;
                     }
                 }
                 if (!empty($search['data']['industry'])) {
                     $industry = strtolower($search['data']['industry']);
                     if (isset($jobIndustries[$industry])) {
                         $jobIndustries[$industry]++;
                     } else {
                         $jobIndustries[$industry] = 1;
                     }
                 }
                 break;
         }
     }
     arsort($subletLocations);
     arsort($jobLocations);
     arsort($jobIndustries);
     return ['subletLocations' => $subletLocations, 'jobLocations' => $jobLocations, 'jobIndustries' => $jobIndustries];
 }