Skip to content

Commit

Permalink
Merge branch 'develop' into USH-1282
Browse files Browse the repository at this point in the history
  • Loading branch information
Mh-Asmi authored Apr 25, 2024
2 parents 24d0774 + 7e6960f commit a439c33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Ushahidi/Modules/V5/DTO/PostSearchFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,24 @@ public function __construct(Request $request)
$this->parent = $this->getParameterAsArray($request->get('parent'));
}

$this->include_unstructured_posts = $request->has('include_unstructured_posts')
? filter_var($request->query('include_unstructured_posts'), FILTER_VALIDATE_BOOLEAN)
: true; // defaulte include unstructured posts
$this->form_condition = "all";
$this->form = []; // no conditions
if (!$request->has('form')) {
if ($request->has('include_unstructured_posts') && !$request->get('include_unstructured_posts')) {
if (!$this->include_unstructured_posts) {
$this->form_condition = "not_null";
$this->form = []; // no conditions
}
} else {
if ($request->get('form') == 'none') {
$this->form = []; // no conditions
$this->form_condition = "null";
} else {
$this->form_condition = "include";
$this->form = $this->getParameterAsArray($request->get('form'));
}
}


if ($request->get('status') == 'all') {
$this->status = []; // no conditions
Expand Down Expand Up @@ -155,7 +156,6 @@ public function __construct(Request $request)

$this->set = $this->getParameterAsArray($request->get('set'));
$this->tags = $this->getParameterAsArray($request->get('tags'));
$this->include_unstructured_posts = $request->query('include_unstructured_posts');
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@ class PostGeometryResource extends BaseResource
*/
public function toArray($request)
{
$map_config = service('map.config');

if (is_a($this->resource, "stdClass")) {
$data = (array) $this->resource;
} else {
$data = $this->resource->toArray();
}

$data['geojson'] = json_decode($data['geojson'], true);

if (isset($data['hide_location']) && $data['hide_location']) {
foreach ($data['geojson']['features'] as $key => $feature) {
$feature['geometry']['coordinates'][0] =
round($feature['geometry']['coordinates'][0], $map_config['location_precision']);
$feature['geometry']['coordinates'][1] =
round($feature['geometry']['coordinates'][1], $map_config['location_precision']);
$data['geojson']['features'][$key] = $feature;
}
}
unset($data['hide_location']);
return $data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ private function getGeoJsonQuery(PostSearchFields $search_fields = null)
$select_raw .= ",Max(IFNULL(messages.type,'web')) as source
,Max(messages.data_source_message_id) as 'data_source_message_id'";
$select_raw .= ",Max(forms.color) as 'marker-color'";
$select_raw .= ",Max(forms.hide_location) as 'hide_location'";
$select_raw .= ",CONCAT(
'{\"type\":\"FeatureCollection\",'
,'\"features\":[',
Expand Down Expand Up @@ -405,8 +406,8 @@ public function getPostsGeoJson(
PostSearchFields $search_fields
) {
$query = $this->getGeoJsonQuery($search_fields);
$query->skip($paging->getSkip())
->orderBy($paging->getOrderBy(), $paging->getOrder());
$query->skip($paging->getSkip());
// ->orderBy('posts.'.$paging->getOrderBy(), $paging->getOrder());
return $query->paginate($paging->getLimit());
}

Expand Down

0 comments on commit a439c33

Please sign in to comment.