Skip to content

Commit

Permalink
Merging Develop into Master (#1730)
Browse files Browse the repository at this point in the history
* Fixing markdown field size bug

* Set up Ushahidi\App namespace and move the simple classes

Migrating the easy, non kohana related stuff into a namespace

* Format for PSR2

* Disable slack notifications from travis

* Adding survey editor update (#1662)

* Adding survey editor update

* Field locking fully working, next fix broken tests

* Fixing tests

* Update Vagrantfile

* Remove extra files

* Updating counts

* Adding entity fields

* Removing unneeded include, simplifying function

* Adding task restriction

* Adding form stage and attribute restriction

* Fixed stage tests

* Updated attribute filitering and added tests

* Fixed linting

* Fixing base data set

* Fixing tests

* removing extraneous char

* Docs: Add more details on use case internals

* 1511 field level locking (#1690)

* Adding survey editor update

* Field locking fully working, next fix broken tests

* Fixing tests

* Update Vagrantfile

* Remove extra files

* Updating counts

* Adding entity fields

* Removing unneeded include, simplifying function

* Adding task restriction

* Adding form stage and attribute restriction

* Fixed stage tests

* Updated attribute filitering and added tests

* Fixed linting

* Fixing base data set

* Fixing tests

* removing extraneous char

* Fixing access permissions

* Fixing test

* Improve categories (#1670)

* adding forms-tags-table #1397

* adding helper-functions for updating forms-tags-relations #1397

* updating forms_tags-table when updating a tag #1397

* updating forms_tags-table when updating/creating an attribute #1397

* adding search-fields for tags #1397

* adding tags to form #1397

* updating forms_tags-table when adding a new survey #1397

* changing naming to tags #1397

* removing updating form_tags when saving an attribute, had got the relation wrong #1397

* lint

* not returning all posts when search->tags is empty #1397

* updating form_attributes when tag is deleted #1397

* updating forms-tags relation when form is updated #1397

* removing old forgotten debug-logging

* resetting post-category-filtering to normal #1397

* adding child-tag-ids to tag #1397

* adding migrations for tags #1397

* fixing failing test #1397

* linting + fix comment from review #1397

* adding migration to move post-tag-values to post_varchar #1397

* Adds language to user (#1659)

* adding language to user #1651

* fixing linting and removing comment #1651

* lint #1651

* Fix from QA (#1705)

* adding forms-tags-table #1397

* adding helper-functions for updating forms-tags-relations #1397

* updating forms_tags-table when updating a tag #1397

* updating forms_tags-table when updating/creating an attribute #1397

* adding search-fields for tags #1397

* adding tags to form #1397

* updating forms_tags-table when adding a new survey #1397

* changing naming to tags #1397

* removing updating form_tags when saving an attribute, had got the relation wrong #1397

* lint

* not returning all posts when search->tags is empty #1397

* updating form_attributes when tag is deleted #1397

* updating forms-tags relation when form is updated #1397

* removing old forgotten debug-logging

* resetting post-category-filtering to normal #1397

* adding child-tag-ids to tag #1397

* adding migrations for tags #1397

* fixing failing test #1397

* linting + fix comment from review #1397

* adding migration to move post-tag-values to post_varchar #1397

* fixing id-error when updating a survey #1397

* Update composer dependencies (#1666)

* Rearranging tests out of application/ into tests/

* Update composer packages to recent versions

- Update PHPUnit
- Update Behat
- Update PHPSpec
- Update aura/di to remove custom fork
- Switch flysystem to 1.0 not 1.1 dev
- Update phinx
- Update phpunit tests for new version
- Update behat tests for new version

* Fix DI to work without auto resolving enabled

* Run codeship builds on PHP 5.6

* Fix travis builds

* Remove bin/tests

* Fix phpunit tests failing while trying to backup globals

Tests were failing with "Serialization of 'Closure' is not allowed"

* Ignore tests/ for linting

* fixup lint

* Fix PHPUnit code coverage, and fix some bugs too

* Don't inject Signer into webhook command

Signer is just overwritten anyway, no need to inject it.
Injection was broken because we didn't pass an auth token

* Fix bin/ushahidi for new symfony/console version

* Fixup coverage reporting from travis

* Try to fix sending files to coveralls

* Add PHP 7.1 to travis builds

* Exclude php 7.1+coverage build

* Add laravel/homestead box and remove puppet scripts

* Update ohanzee/database to our fork, and select only aggregates when counting

Mysql 5.7 doesn't like selecting both grouped and non grouped info in
the same query. So we're not resetting the select fields before adding
aggregates (ie. count) to the query

* Remove posts?current_stage filter as its not working, and fails hard in mysql 5.7

* Set mysql strict mode in travis

* Reset order by clause when fetching count queries too

* Fix posts stats to work with mysql only_full_group_by mode

* Output mysql version from travis builds

* Use MAX() instead of ANY_VALUE() in queries

ANY_VALUE only exists in mysql 5.7+
  • Loading branch information
willdoran authored May 3, 2017
1 parent 995ee2c commit 1c2d184
Show file tree
Hide file tree
Showing 86 changed files with 2,727 additions and 2,866 deletions.
5 changes: 5 additions & 0 deletions .env.travis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_TYPE=MySQLi
DB_HOST=127.0.0.1
DB_NAME=ushahidi
DB_PASS=
DB_USER=travis
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,42 @@ sudo: false
# secure: NxhzhKGYnZYZiWVZM4w1PlZpTy9bbmNlvbqjL+9d4PvK4hFzPwQU12CchhBPeXNGLWBHg/ti6Scn/t5XIS3YJrkk4ydWmJBht5UId8uFZ1A7GCUnNNPTt2RG55lbJJdZSj01rOGZjEQbE5RyckEjgRzhZjdZ+HsjoPaRzWIBrvE=
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
env:
- coverage="--coverage"
- coverage=""
matrix:
exclude:
- php: '5.5'
- php: '7.0'
env: coverage="--coverage"
- php: '7.1'
env: coverage="--coverage"
allow_failures:
- env: coverage="--coverage"
- php: '7.1'
fast_finish: true
cache:
directories:
- "$HOME/.composer/cache"
services:
- mysql
before_install:
- mysql -e 'CREATE DATABASE ushahidi;'
- mysql -e "select version();"
- mysql -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"
- cp .env.travis .env
install:
- composer install --no-interaction
before_script:
- "./bin/tests install"
- composer pre-test
- if [ "${coverage}" == "" ]; then php -S localhost:8000 -t httpdocs httpdocs/index.php & fi
- if [ "${coverage}" != "" ]; then php -S localhost:8000 -t httpdocs httpdocs/coverage.php & fi
- mysql -e 'SET @@GLOBAL.wait_timeout=1800'
script:
- "./bin/tests run --no-install $coverage"
- if [ "${coverage}" == "" ]; then composer test; fi
- if [ "${coverage}" != "" ]; then composer run coverage --timeout=0; fi
- composer lint
after_success:
- if [ "${coverage}" != "" ]; then travis_retry bin/coveralls -v; fi
Expand Down
27 changes: 27 additions & 0 deletions Homestead.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ip: 192.168.33.110
memory: 1024
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
-
map: "./"
to: /vagrant
type: "nfs"
-
map: "./"
to: /home/vagrant/Code/platform-api
type: "nfs"
sites:
-
map: api.ushahidi.app
to: /home/vagrant/Code/platform-api/httpdocs
-
map: ushv3.dev
to: /home/vagrant/Code/platform-api/httpdocs
databases:
- ushahidi
name: platform-api
hostname: platform-api
6 changes: 0 additions & 6 deletions Puppetfile

This file was deleted.

76 changes: 43 additions & 33 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
# Basic apache dev box complete with phpunit
# ready to go for ushahidi dev
Vagrant.configure("2") do |config|
config.vm.box = "puppetlabs/ubuntu-14.04-64-puppet" # vagrantcloud
config.vm.hostname = "ushahidi-platform.dev"
config.vm.network "private_network", ip: "192.168.33.110"
config.vm.synced_folder "./", "/var/www", id: "vagrant-root", :nfs => true
config.vm.network "forwarded_port", guest: 22, host: 2210
config.ssh.port = 2210

config.vm.provider :virtualbox do |virtualbox|
virtualbox.customize ["modifyvm", :id, "--name", "ushahidi-platform"]
virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
virtualbox.customize ["modifyvm", :id, "--memory", "512"]
virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

config.vm.provision :shell do |shell|
# upgrade all packages (including puppet) before using the puppet provisioner.
# this excludes grub-pc since the hard drive id changes between VMs and will cause
# an interactive prompt to appear and then error out, breaking the provisioning step.
shell.inline = "DEBIAN_FRONTEND=noninteractive apt-mark hold grub-pc && apt-get update -y && apt-get upgrade -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'"
end

config.vm.provision :puppet do |puppet|
puppet.environment_path = "puppet/"
puppet.environment = "platform"
puppet.options = ["--verbose"]
puppet.facter = {
# Optionally pass in a github oauth token through an environment variable
"github_token" => ENV.fetch('github_token', '')
}
end
# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))

homesteadYamlPath = File.expand_path("Homestead.yaml", File.dirname(__FILE__))
homesteadJsonPath = File.expand_path("Homestead.json", File.dirname(__FILE__))
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.require_version '>= 1.9.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exist? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
config.vm.provision "shell" do |s|
s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
end
end

if File.exist? homesteadYamlPath then
settings = YAML::load(File.read(homesteadYamlPath))
elsif File.exist? homesteadJsonPath then
settings = JSON.parse(File.read(homesteadJsonPath))
else
abort "Homestead settings file not found in #{confDir}"
end

Homestead.configure(config, settings)

if File.exist? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath, privileged: false
end

if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
end
end
22 changes: 0 additions & 22 deletions application/classes/ORM.php

This file was deleted.

60 changes: 0 additions & 60 deletions application/classes/Unittest/Database/TestCase.php

This file was deleted.

6 changes: 0 additions & 6 deletions application/classes/Ushahidi/Console/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Ushahidi_Console_Webhook extends Command
private $postRepository;
private $webhookRepository;
private $webhookJobRepository;
private $signer;
private $client;

public function setDatabase(Database $db)
Expand All @@ -48,11 +47,6 @@ public function setPostRepo(PostRepository $repo)
$this->postRepository = $repo;
}

public function setSigner(Signer $signer)
{
$this->signer = $signer;
}

public function setWebhookJobRepo(WebhookJobRepository $repo)
{
$this->webhookJobRepository = $repo;
Expand Down
2 changes: 1 addition & 1 deletion application/classes/Ushahidi/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public static function init()
$di->setter['Ushahidi\Console\Application']['injectCommands'][] = $di->lazyNew('Ushahidi_Console_Webhook');
$di->setter['Ushahidi_Console_Webhook']['setDatabase'] = $di->lazyGet('kohana.db');
$di->setter['Ushahidi_Console_Webhook']['setPostRepo'] = $di->lazyGet('repository.post');
$di->setter['Ushahidi_Console_Webhook']['setSigner'] = $di->lazyGet('tool.signer');
$di->setter['Ushahidi_Console_Webhook']['setWebhookRepo'] = $di->lazyGet('repository.webhook');
$di->setter['Ushahidi_Console_Webhook']['setWebhookJobRepo'] = $di->lazyGet('repository.webhook.job');

Expand Down Expand Up @@ -289,6 +288,7 @@ public static function init()

// Validation Trait
$di->setter['Ushahidi\Core\Tool\ValidationEngineTrait']['setValidation'] = $di->newFactory('Ushahidi_ValidationEngine');
$di->params['Ushahidi_ValidationEngine']['array'] = [];

// Formatter mapping
$di->params['Ushahidi\Factory\FormatterFactory']['map'] = [
Expand Down
5 changes: 4 additions & 1 deletion application/classes/Ushahidi/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function getSearchTotal()
{
// Assume we can simply count the results to get a total
$query = $this->getSearchQuery(true)
->resetSelect()
->select([DB::expr('COUNT(*)'), 'total']);

// Fetch the result and...
Expand Down Expand Up @@ -170,7 +171,8 @@ protected function getSearchQuery($countable = false)
if ($countable) {
$query
->limit(null)
->offset(null);
->offset(null)
->resetOrderBy();
}

return $query;
Expand All @@ -197,6 +199,7 @@ protected function selectOne(Array $where = [])
protected function selectCount(Array $where = [])
{
$result = $this->selectQuery($where)
->resetSelect()
->select([DB::expr('COUNT(*)'), 'total'])
->execute($this->db);
return $result->get('total') ?: 0;
Expand Down
Loading

0 comments on commit 1c2d184

Please sign in to comment.