From a7c7e01abb66ee5ec83f9723893399218b1a1c2b Mon Sep 17 00:00:00 2001 From: David Losada Date: Thu, 16 Apr 2020 19:53:36 +0200 Subject: [PATCH 1/2] fix(post-entity): address regression with handling posts when forms have two location fields #3922 --- src/App/Repository/PostRepository.php | 33 +++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/App/Repository/PostRepository.php b/src/App/Repository/PostRepository.php index eb729fb6d8..71f7e4cc36 100644 --- a/src/App/Repository/PostRepository.php +++ b/src/App/Repository/PostRepository.php @@ -35,7 +35,9 @@ use Ushahidi\App\Multisite\OhanzeeResolver; use Ushahidi\Core\Tool\Permissions\InteractsWithPostPermissions; +use Illuminate\Support\Collection; use League\Event\ListenerInterface; + use Ushahidi\Core\Traits\Event; class PostRepository extends OhanzeeRepository implements @@ -249,13 +251,30 @@ public function getEntity(array $data = null): Post /* Check which types are used in the form */ $form_attributes = $this->form_attributes_by_form->get(intval($data['form_id'])); if ($form_attributes) { - $types_to_fetch = $form_attributes - ->pluck('type') - ->unique() - ->toArray(); - - /* Intersect with requested types, subtract types already provided in $data */ - $types_to_fetch = array_intersect($types_to_fetch, $this->include_value_types); + /* Count how many of each form attribute type we have */ + $types_to_fetch_with_attribute_count = $form_attributes + ->groupBy('type') + ->map(function ($attrs) { + return $attrs->count(); + }); + + $types_to_fetch = $types_to_fetch_with_attribute_count->keys()->toArray(); + + /* Intersect with requested types */ + if (count($this->include_value_types) > 0) { + $types_to_fetch = array_intersect($types_to_fetch, $this->include_value_types); + } + + /* drop types that we have already fetched + BUT only if there is a SINGLE attribute of that type in the form, + since the SQL JOINs that we have run previously are only good for fetching + a SINGLE value of each type for each post. + If we don't do this, we would be leaving out the values of the second + and subsequent attributes defined with that type */ + $already_obtained_types = collect($already_obtained_types) + ->filter(function ($type) use ($types_to_fetch_with_attribute_count) { + return $types_to_fetch_with_attribute_count->get($type) < 2; + })->toArray(); $types_to_fetch = array_diff($types_to_fetch, $already_obtained_types); } } From 11ff8c6c3ad94d1c0129f630c6b0202adfc8db8f Mon Sep 17 00:00:00 2001 From: David Losada Date: Fri, 17 Apr 2020 19:38:54 +0000 Subject: [PATCH 2/2] GitBook: [develop] one page modified --- .../setup_alternatives/platform_release_install.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/development-and-code/setup_alternatives/platform_release_install.md b/docs/development-and-code/setup_alternatives/platform_release_install.md index f7074b676f..4130436bd8 100644 --- a/docs/development-and-code/setup_alternatives/platform_release_install.md +++ b/docs/development-and-code/setup_alternatives/platform_release_install.md @@ -121,6 +121,14 @@ The latest releases of the Ushahidi Platform come with a little handy tool calle If something is wrong, this tool may provide you with useful information about what exactly seems to be the cause. +## Connecting the mobile app + +Please note that the mobile app relies on the contents of the "config.json" file in order to connect to the API backend. + +In order to help the app find the backend, ensure that the key `backend_url` in the JSON file is set appropriately to the absolute public URL of your deployment \(i.e. `"backend_url": "https://example.deployment.com"` \) + +If you are running the Docker container, you may set this variable using the `SITE_URL` environment variable. \(In the default install the site URL **is** the backend URL\). + ## Queue drivers \(and "sync" driver issues\) The Ushahidi Platform API uses a queue system for running some end-user requested operations in the background. At the moment of this writing, such operations are CSV importing and exporting. More may come up in the future.