Skip to content

Commit

Permalink
Merge 09c2ae4 into ef4ce31
Browse files Browse the repository at this point in the history
  • Loading branch information
rowasc committed Nov 9, 2018
2 parents ef4ce31 + 09c2ae4 commit f0ffa15
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 24 deletions.
25 changes: 10 additions & 15 deletions CONTRIBUTING.md
@@ -1,16 +1,11 @@
This is the repository for the Ushahidi v3 API
## Getting Involved
There are many ways to get involved with Ushahidi, and some of them are great even for first time contributors. If you never contributed to Open Source Software before, or need more guidance doing it, please jump in our [gitter](https://gitter.im/ushahidi/Community) channel with a clear description of what you are trying to do, and someone in there will try to help you.
These are some ways to get involved:

* If logging an issue:
* Please include steps to reproduce the issue - what page does it occur, what went wrong
* Please include any error messages
* Please include screenshot(s) where possible

* If you want to help out with development:
* Find the docs at [ushahidi.com/support](http://www.ushahidi.com/support/)
* Have a read through the [developer guide](http://docs.ushahidi.org/developer-guide/index.html)
* Have a look at the [Community Tasks](https://github.com/ushahidi/platform/labels/Community%20Task) or other [open issues](https://github.com/ushahidi/platform/issues)
* Join one of the [developer chats](http://docs.ushahidi.com/get-involved.html) and tell us what you're working on
* Send pull requests!

Thanks,
The Ushahidi Team
- **Documentation**: if you find an area of the Ushahidi platform that could use better docs, we would love to hear from you in an issue, and would be seriously excited if you send a [Pull Request](https://github.com/ushahidi/platform/compare). This is a great way to get involved even if you are not technical or just have a passion to make information more available and clear to everyone.
- **Report a bug**: If you found an issue/bug, please report it [here](https://github.com/ushahidi/platform/issues). Someone on the team will jump in to check it, try to help, and prioritize it for future development depending on the issue type. Please follow the bug report template to allow others to reproduce it easily.
- **Fix a bug**: If you want to contribute a fix for a bug you or someone else found, we will be happy to review your PR and provide support. Tasks that are suggested for the community can be found by searching for the https://github.com/ushahidi/platform/labels/Community%20Task tag. Please add a comment notifying others that you will be working on a task before you start.
- **Helping other users in the community**: you are welcome and encouraged to jump in and help other members of the community, either by responding to issues in github or jumping into our community channels to answer questions.
- **New features**: our features are generally driven by our product and engineering team members, but if you have a great idea, or found a user need that we haven't covered, you are more than welcome to make a suggestion in the form of a github issue [here](https://github.com/ushahidi/platform/issues), or reach out to Ushahidi staff in [gitter](https://gitter.im/ushahidi/Community)
- **Security issues**: if you think you have found a security issue, please follow
[this link where we explain our disclosure and reporting policies](https://www.ushahidi.com/security)
26 changes: 25 additions & 1 deletion README.md
Expand Up @@ -14,7 +14,9 @@ Ushahidi 3

[![Build Status](https://travis-ci.org/ushahidi/platform.png)](https://travis-ci.org/ushahidi/platform)
[![Coverage Status](https://coveralls.io/repos/github/ushahidi/platform/badge.svg)](https://coveralls.io/github/ushahidi/platform)
[![Backers on Open Collective](https://opencollective.com/platform/backers/badge.svg)](#backers)

[![Sponsors on Open Collective](https://opencollective.com/platform/sponsors/badge.svg)](#sponsors)


[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
Expand All @@ -24,7 +26,7 @@ Ushahidi 3
Ushahidi is an open source web application for information collection, visualization and interactive mapping. It helps you to collect info from: SMS, Twitter, RSS feeds, Email. It helps you to process that information, categorize it, geo-locate it and publish it on a map.

## A note for grassroots organizations
If you are starting a deployment for a grassroots organization, you can apply for a free social-impact responder account [here](https://www.ushahidi.com/plans/apply-for-free) after verifying that you meet the criteria.
If you are starting a deployment for a grassroots organization, you can apply for a free social-impact responder account [here](https://www.ushahidi.com/pricing/apply-for-free) after verifying that you meet the criteria.


## Getting Involved
Expand Down Expand Up @@ -126,6 +128,28 @@ Follow the instructions [here](docs/setup_alternatives/XAMPP.md)

- The latest install instructions for the client are always [in the platform-client README, at this url](https://github.com/ushahidi/platform-client/blob/develop/README.md).

## Credits

### Contributors

This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].

<a href="graphs/contributors"><img src="https://opencollective.com/platform/contributors.svg?width=890&button=false" /></a>

### Backers

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/platform#backer)]

<a href="https://opencollective.com/platform#backers" target="_blank"><img src="https://opencollective.com/platform/backers.svg?width=890"></a>

### Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/platform#sponsor)]

<a href="https://opencollective.com/platform/sponsor/0/website" target="_blank"><img src="https://opencollective.com/platform/sponsor/0/avatar.svg"></a>



## Useful Links

- [Download][download]
Expand Down
Expand Up @@ -40,7 +40,7 @@ public function show(Request $request)
'offset' => $request->input('offset', 0),
'add_header' => $include_header
];
Log::debug('In CLI Controller' . var_export($filters, true));
Log::debug('In CLI Controller ' . var_export($filters, true));
// Get the usecase and pass in authorizer, payload and transformer
$this->usecase = $this->usecaseFactory->get('posts_export', 'export')
->setFilters($filters)
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/API/Posts/GeoJSONController.php
Expand Up @@ -55,9 +55,11 @@ public function index(Request $request)
{
$this->prepBoundingBox($request);

$filters = $this->demoCheck($this->getFilters($request));

$this->usecase = $this->usecaseFactory
->get($this->getResource(), 'search')
->setFilters($this->getFilters($request))
->setFilters($filters)
->setIdentifiers($this->getIdentifiers($request))
->setFormatter(service('formatter.entity.post.geojsoncollection'));

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/API/Posts/PostsController.php
Expand Up @@ -84,9 +84,10 @@ public function store(Request $request)
*/
public function index(Request $request)
{
$filters = $this->demoCheck($this->getFilters($request));
$this->usecase = $this->usecaseFactory
->get($this->getResource(), 'search')
->setFilters($this->getFilters($request))
->setFilters($filters)
->setIdentifiers($this->getIdentifiers($request));

return $this->prepResponse($this->executeUsecase($request), $request);
Expand Down
24 changes: 24 additions & 0 deletions app/Http/Controllers/RESTController.php
Expand Up @@ -56,6 +56,30 @@ public static function version()
return self::$version;
}

public function demoCheck($filters)
{
$isDemoTier = service('site.config')['tier'] === 'demo_1';
if ($isDemoTier) {
// Demo deployments are limited to the first 25 posts,
// if any thing other more than that or a different offset is request
// none will be returned
if (array_key_exists('offset', $filters)
&& array_key_exists('limit', $filters)) {
if ($filters['offset'] + $filters['limit'] > 25) {
$diff = 25 - $filters['offset'];
$filters['limit'] = $diff > 0 ? $diff : 0;
}
} else {
$limit = 25;
if (array_key_exists('limit', $filters)) {
$limit = $filters['limit'];
}
$filters['limit'] = $limit > 25 ? 25 : $limit;
}
}
return $filters;
}

/**
* Get an API URL for a resource.
* @param string $resource
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckDemoExpiration.php
Expand Up @@ -18,7 +18,7 @@ class CheckDemoExpiration
public function handle($request, Closure $next, $guard = null)
{
$multisite = config('multisite.enabled');
$isDemoTier = service('site.config')['tier'] === 'demo';
$isDemoTier = service('site.config')['tier'] === 'demo_1';
$isNotGet = !$request->isMethod('get');

if ($multisite && $isNotGet && $isDemoTier) {
Expand Down
1 change: 0 additions & 1 deletion src/App/Repository/OhanzeeRepository.php
Expand Up @@ -110,7 +110,6 @@ public function setSearchParams(SearchData $search)
if (!empty($sorting['offset'])) {
$this->search_query->offset(intval($sorting['offset']));
}

if (!empty($sorting['limit'])) {
$this->search_query->limit(intval($sorting['limit']));
}
Expand Down
29 changes: 29 additions & 0 deletions src/App/Repository/PostRepository.php
Expand Up @@ -226,6 +226,35 @@ protected function selectQuery(array $where = [])
return $query;
}

// SearchRepository
public function setSearchParams(SearchData $search)
{
$this->search_query = $this->selectQuery();

$sorting = $search->getSorting();

if (!empty($sorting['orderby'])) {
$order = isset($sorting['order']) ? strtoupper($sorting['order']) : 'ASC';
$this->search_query->order_by(
$this->getTable() . '.' . $sorting['orderby'],
($order == 'DESC' ? 'DESC' : 'ASC')
);
}

if (!empty($sorting['offset'])) {
$this->search_query->offset(intval($sorting['offset']));
}

if (array_key_exists('limit', $sorting)
&& $sorting['limit'] >= 0
&& strlen($sorting['limit'])) {
$this->search_query->limit(intval($sorting['limit']));
}

// apply the unique conditions of the search
$this->setSearchConditions($search);
}

protected function getPostValues($id, $excludePrivateValues, $excludeStages)
{

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/bootstrap/RestContext.php
Expand Up @@ -278,9 +278,9 @@ public function iRequest($pageUrl)

// Get response object
$this->response = $response;
$data = $this->response->getBody(true);
$data = explode("\n", $data);
\Log::info(print_r($data, true));
// $data = $this->response->getBody(true);
// $data = explode("\n", $data);
// \Log::info(print_r($data, true));
}

/**
Expand Down

0 comments on commit f0ffa15

Please sign in to comment.