Skip to content

Commit

Permalink
max geo_width and geo_width_km for aggregator mode (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbraswell authored Jan 10, 2023
1 parent f7e022c commit 0301f3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/Http/Controllers/Query/SwitcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public function get(Request $request, string $dataFormat)

private function getSearchResults(Request $request): BaseJsonResponse
{
$isAggregatorMode = (bool)legacy_config('aggregator_mode_enabled');

$meetingIds = $request->input('meeting_ids');
$meetingIds = !is_null($meetingIds) ? ensure_integer_array($meetingIds) : null;

Expand Down Expand Up @@ -158,10 +160,18 @@ private function getSearchResults(Request $request): BaseJsonResponse
$sortResultsByDistance = false;
$needsDistanceField = false;
if (!is_null($latitude) || !is_null($longitude)) {
$geoWidthMiles = $request->input('geo_width');
$geoWidthMiles = is_numeric($geoWidthMiles) ? floatval($geoWidthMiles) : null;
$geoWidthKilometers = $request->input('geo_width_km');
$geoWidthKilometers = is_numeric($geoWidthKilometers) ? floatval($geoWidthKilometers) : null;
$geoWidthMiles = $request->input('geo_width');
$geoWidthMiles = is_numeric($geoWidthMiles) ? floatval($geoWidthMiles) : null;

if ($isAggregatorMode) {
$maxGeoWidthKilometers = legacy_config('aggregator_max_geo_width_km');
$maxGeoWidthMiles = $maxGeoWidthKilometers * 0.621371;
$geoWidthKilometers = !is_null($geoWidthKilometers) && $geoWidthKilometers > $maxGeoWidthKilometers ? $maxGeoWidthKilometers : $geoWidthKilometers;
$geoWidthMiles = !is_null($geoWidthMiles) && $geoWidthMiles > $maxGeoWidthMiles ? $maxGeoWidthMiles : $geoWidthMiles;
}

$sortResultsByDistance = $request->input('sort_results_by_distance') == '1';
$dataFieldKeys = $request->input('data_field_key');
$dataFieldKeys = !is_null($dataFieldKeys) ? explode(',', $dataFieldKeys) : [];
Expand Down Expand Up @@ -244,7 +254,6 @@ private function getSearchResults(Request $request): BaseJsonResponse
$pageNum = is_numeric($pageNum) ? intval($pageNum) : 1;
}

$isAggregatorMode = (bool)legacy_config('aggregator_mode_enabled');
$rootServersInclude = null;
$rootServersExclude = null;

Expand Down
1 change: 1 addition & 0 deletions src/app/LegacyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private static function loadConfig()
$config['default_closed_status'] = $g_defaultClosedStatus ?? true;
$config['enable_language_selector'] = $g_enable_language_selector ?? false;
$config['aggregator_mode_enabled'] = $aggregator_mode_enabled ?? false;
$config['aggregator_max_geo_width_km'] = isset($aggregator_max_geo_width_km) && is_numeric($aggregator_max_geo_width_km) ? floatval($aggregator_max_geo_width_km) : 1000;

self::$config = $config;
self::$configLoaded = true;
Expand Down

0 comments on commit 0301f3c

Please sign in to comment.