Skip to content

Commit

Permalink
Merge pull request #1 from publicwhip/rb-0.3.1
Browse files Browse the repository at this point in the history
Mainly adding missing data for milestone 0.3.1
  • Loading branch information
rbairwell authored Mar 14, 2019
2 parents 0467fd0 + 4ceee64 commit fbf50c1
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 84 deletions.
60 changes: 60 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
build:
docker:
# Specify the version you desire here
- image: circleci/php:7.3.3

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# Using the RAM variation mitigates I/O contention
# for database intensive operations.
# - image: circleci/mysql:5.7-ram
#
# - image: redis:2.8.19

steps:
- checkout

- run: sudo apt update
- run: sudo docker-php-ext-install pdo_mysql

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "composer.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: Display PHP information
command: |
php -v
composer --version
- run:
name: Install project dependencies
command: |
composer install -n --prefer-dist
- save_cache:
key: v1-dependencies-{{ checksum "composer.lock" }}
paths:
- ./vendor

# prepare the database
#- run: touch storage/testing.sqlite
#- run: php artisan migrate --env=testing --database=sqlite_testing --force

# run tests
- run:
name: Run Unit tests
command: ./vendor/bin/phpunit -c ./qaTools/phpunit.xml
- run:
name: Run Grumphp
command: ./vendor/bin/grumphp run
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# .gitattributes
tests/ export-ignore
docker/ export-ignore
qa/ export-ignore
qaTools/ export-ignore
docs/ export-ignore
database/ export-ignore

# Auto detect text files and perform LF normalization
* text=auto
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ To see what else has been achieved so far, please have a look at the [Milestones

If you are considering [Contributing](docs/CONTRIBUTING.md) to the development of PublicWhip v2, please ensure you have
read the [Code of Conduct](docs/CODE_OF_CONDUCT.md) first. All contributions to PublicWhip v2 must be licensed under
the [MIT](LICENSE.txt) license allowing free usage of the code in any form without restriction.
the [MIT](LICENSE.txt) license allowing free usage of the code in any form without restriction.

[![Coverage Status](https://coveralls.io/repos/github/publicwhip/publicwhipv2/badge.svg?branch=master)](https://coveralls.io/github/publicwhip/publicwhipv2?branch=master)
[![CircleCI](https://circleci.com/gh/publicwhip/publicwhipv2/tree/master.svg?style=svg)](https://circleci.com/gh/publicwhip/publicwhipv2/tree/master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Slack Join Chat](https://img.shields.io/badge/Slack-Join_Chat-blue.svg)](https://join.slack.com/t/publicwhip/shared_invite/enQtNTczMTg1MTc1Mzc3LTAxMjkyYzNhNWY0NDdmY2EzYjYwNTZjNjQ1YTNiOTQwZWYzM2Q0ZDJjOWU5MTVjNzZmNGFjMzljY2U0ZjA0YjM)
124 changes: 65 additions & 59 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,68 @@
{
"name": "bairwell/publicwhip",
"description": "Publicwhip v2 website",
"type": "project",
"homepage": "https://www.publicwhip.org.uk/",
"require": {
"php": ">=7.2",
"ext-pdo": "*",
"slim/slim": "^3",
"psr/log": "^1",
"twig/twig": "^2",
"slim/twig-view": "^2",
"monolog/monolog": "^1.24",
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^2.0",
"psr/http-message": "^1.0",
"psr/container": "^1",
"slim/csrf": "^0.5",
"slim/flash": "^0.1",
"maximebf/debugbar": "^1.15",
"swiftmailer/swiftmailer": "^5.4",
"illuminate/database": "^5.1",
"illuminate/events": "^5.1",
"illuminate/container": "^5.8",
"illuminate/support": "^5.8",
"illuminate/contracts": "^5.8",
"slim/http-cache": "^0.4.0",
"erusev/parsedown": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "^8",
"roave/security-advisories": "dev-master",
"phpstan/phpstan-strict-rules": "^0.11",
"phpmd/phpmd": "^2",
"maglnet/composer-require-checker": "^1",
"phpro/grumphp": "^0.15",
"phpstan/phpstan": "^0.11",
"sensiolabs/security-checker": "^5",
"squizlabs/php_codesniffer": "^3",
"infection/infection": "^0.12",
"sebastian/phpcpd": "^4",
"jakub-onderka/php-parallel-lint": "^1.0"
},
"license": "MIT",
"authors": [
{
"name": "Richard Bairwell",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/publicwhip/publicwhipv2/issues",
"docs": "https://github.com/publicwhip/publicwhip/tree/master/docs",
"name": "bairwell/publicwhip",
"description": "Publicwhip v2 website",
"type": "project",
"homepage": "https://www.publicwhip.org.uk/",
"require": {
"php": ">=7.2",
"ext-pdo": "*",
"slim/slim": "^3",
"psr/log": "^1",
"twig/twig": "^2",
"slim/twig-view": "^2",
"monolog/monolog": "^1.24",
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^2.0",
"psr/http-message": "^1.0",
"psr/container": "^1",
"slim/csrf": "^0.5",
"slim/flash": "^0.1",
"maximebf/debugbar": "^1.15",
"swiftmailer/swiftmailer": "^5.4",
"illuminate/database": "^5.1",
"illuminate/events": "^5.1",
"illuminate/container": "^5.8",
"illuminate/support": "^5.8",
"illuminate/contracts": "^5.8",
"slim/http-cache": "^0.4.0",
"erusev/parsedown": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "^8",
"roave/security-advisories": "dev-master",
"phpstan/phpstan-strict-rules": "^0.11",
"phpmd/phpmd": "^2",
"maglnet/composer-require-checker": "^1",
"phpro/grumphp": "^0.15",
"phpstan/phpstan": "^0.11",
"sensiolabs/security-checker": "^5",
"squizlabs/php_codesniffer": "^3",
"infection/infection": "^0.12",
"sebastian/phpcpd": "^4",
"jakub-onderka/php-parallel-lint": "^1.0"
},
"scripts": {
"style": "phpcs --standard=./qaTools/phpcs.xml",
"test": "phpunit",
"format-code": "php-cs-fixer fix --allow-risky=yes",
"phpstan": "phpstan analyse -l 6 -c qaTools/phpstan.neon src"
},
"license": "MIT",
"authors": [
{
"name": "Richard Bairwell",
"email": "[email protected]"
},
"autoload": {
"psr-4": {
"PublicWhip\\": "src/"
}
},
"minimum-stability": "stable"
}
],
"support": {
"issues": "https://github.com/publicwhip/publicwhipv2/issues",
"docs": "https://github.com/publicwhip/publicwhip/tree/master/docs",
"email": "[email protected]"
},
"autoload": {
"psr-4": {
"PublicWhip\\": "src/"
}
},
"minimum-stability": "stable"
}
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 47 additions & 15 deletions database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,37 @@ It is automatically loaded into docker whenever the `docker-composer up --build`

The data was anonymised/reduced using:
```sql
# Remove unwanted tables
SELECT CONCAT('DROP TABLE ',GROUP_CONCAT(CONCAT('`publicwhip-db`.`',table_name,'`')),';')
INTO @dropcmd
FROM information_schema.TABLES
WHERE TABLE_SCHEMA='publicwhip-db'
AND (TABLE_NAME LIKE 'phpbb3\_%' OR TABLE_NAME LIKE 'phpbb_%');

PREPARE stmt FROM @dropcmd;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

# Remove private dream mp (policies) entries.
DELETE FROM pw_dyn_dreammp WHERE private=1;
DELETE FROM pw_cache_dreaminfo WHERE dream_id NOT IN (SELECT dream_id FROM pw_dyn_dreammp);
DELETE FROM pw_cache_dreamreal_distance WHERE dream_id NOT IN (SELECT dream_id FROM pw_dyn_dreammp);
DELETE FROM pw_dyn_dreamvote WHERE dream_id NOT IN (SELECT dream_id FROM pw_dyn_dreammp);

# Remove users which are not used anywhere.
DELETE FROM pw_dyn_user WHERE user_id NOT IN (
SELECT DISTINCT(user_id) FROM (
SELECT wm.user_id FROM pw_dyn_wiki_motion AS wm
UNION
SELECT al.user_id FROM pw_dyn_auditlog AS al
UNION
SELECT dm.user_id FROM pw_dyn_dreammp AS dm
) AS users);


# anonymise the auditlog
UPDATE `pw_dyn_auditlog` SET remote_addr=CONCAT('172.16.',FLOOR(RAND() * 253) +1,'.',FLOOR(RAND() * 253) +1),event='- Removed -';

# anonymise the users entries
UPDATE `pw_dyn_user` SET user_name=CONCAT('User ',user_id),
real_name=CONCAT('Real ',user_id,' Name'),
email=CONCAT('user',user_id,'@example.com'),
Expand All @@ -31,19 +52,30 @@ Yes, version 1 does store the passwords in MD5(!).
and then exported:

```bash
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_cache_divinfo > pw_cache_divinfo.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_cache_divwiki > pw_cache_divwiki.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_cache_mpinfo > pw_cache_mpinfo.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_cache_partyinfo > pw_cache_partyinfo.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_cache_whip > pw_cache_whip.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_constituency > pw_constituency.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_division > pw_division.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_dyn_auditlog > pw_dyn_auditlog.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_dyn_user > pw_dyn_user.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_dyn_wiki_motion > pw_dyn_wiki_motion.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_moffice > pw_moffice.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_mp > pw_mp.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_vote > pw_vote.sql
docker exec publicwhip-mariadb /usr/bin/mysqldump -u root --password=root publicwhip-db pw_vote_sortorder > pw_vote_sortorder.sql
docker exec -it publicwhip-mariadb /bin/bash


mysqldump -u root --password=root publicwhip-db pw_cache_divinfo > /docker-entrypoint-initdb.d/pw_cache_divinfo.sql
mysqldump -u root --password=root publicwhip-db pw_cache_divwiki > /docker-entrypoint-initdb.d/pw_cache_divwiki.sql
mysqldump -u root --password=root publicwhip-db pw_cache_mpinfo > /docker-entrypoint-initdb.d/pw_cache_mpinfo.sql
mysqldump -u root --password=root publicwhip-db pw_cache_partyinfo > /docker-entrypoint-initdb.d/pw_cache_partyinfo.sql
mysqldump -u root --password=root publicwhip-db pw_cache_whip > /docker-entrypoint-initdb.d/pw_cache_whip.sql
mysqldump -u root --password=root publicwhip-db pw_constituency > /docker-entrypoint-initdb.d/pw_constituency.sql
mysqldump -u root --password=root publicwhip-db pw_division > /docker-entrypoint-initdb.d/pw_division.sql
mysqldump -u root --password=root publicwhip-db pw_dyn_auditlog > /docker-entrypoint-initdb.d/pw_dyn_auditlog.sql
mysqldump -u root --password=root publicwhip-db pw_dyn_user > /docker-entrypoint-initdb.d/pw_dyn_user.sql
mysqldump -u root --password=root publicwhip-db pw_dyn_wiki_motion > /docker-entrypoint-initdb.d/pw_dyn_wiki_motion.sql
mysqldump -u root --password=root publicwhip-db pw_moffice > /docker-entrypoint-initdb.d/pw_moffice.sql
mysqldump -u root --password=root publicwhip-db pw_mp > /docker-entrypoint-initdb.d/pw_mp.sql
mysqldump -u root --password=root publicwhip-db pw_vote > /docker-entrypoint-initdb.d/pw_vote.sql
mysqldump -u root --password=root publicwhip-db pw_vote_sortorder > /docker-entrypoint-initdb.d/pw_vote_sortorder.sql
# Now for the policies
mysqldump -u root --password=root publicwhip-db pw_cache_dreaminfo > /docker-entrypoint-initdb.d/pw_cache_dreaminfo.sql
mysqldump -u root --password=root publicwhip-db pw_cache_dreamreal_distance > /docker-entrypoint-initdb.d/pw_cache_dreamreal_distance.sql
mysqldump -u root --password=root publicwhip-db pw_dyn_dreammp > /docker-entrypoint-initdb.d/pw_dyn_dreammp.sql
mysqldump -u root --password=root publicwhip-db pw_dyn_dreamvote > /docker-entrypoint-initdb.d/pw_dyn_dreamvote.sql
# and compress them all
gzip /docker-entrypoint-initdb.d/*.sql


```
Binary file added database/pw_cache_dreaminfo.sql.gz
Binary file not shown.
Binary file added database/pw_cache_dreamreal_distance.sql.gz
Binary file not shown.
Binary file added database/pw_dyn_dreammp.sql.gz
Binary file not shown.
Binary file added database/pw_dyn_dreamvote.sql.gz
Binary file not shown.
12 changes: 10 additions & 2 deletions docs/Milestones.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

Division motion text is stored in a custom 'wiki' format which needs to be parsed.

* 0.5 - Create basic division editing system (with no authentication) : Estimate 3-4 days
* 0.4.5 - Create basic division editing system (with no authentication) : Estimate 3-4 days

* 0.5 - Show/List policies (aka "dreams" in v1 database). Estimate 1 day

* 0.5.5 - Add ability to modify policies. Estimate 2 days.

* 0.6 - Add authentication. Estimate 2-3 days.

Expand All @@ -19,7 +23,7 @@
* 0.7 - Add basic votes display on divisions. Estimate 2-3 days.
* 0.8 - Replace existing configuration system to a simpler one using `.env` files. Estimate 1 day
* 0.9 - Ensure templates, routing and dependency injector are cached on production. Estimate 1 day
* 0.10 - Get a better web site design in place.
* 0.10 - Get a better web site design in place. Estimate 4 days.
* 0.11 - Ensure adequate logging/instrumentation is in place. Estimate 1 day
* 0.21 - Get unit test coverage to at least 20% with those tests then being fully mutation covered.
Estimate 3-4 days.
Expand Down Expand Up @@ -50,6 +54,10 @@

## <a name="completed">Completed Milestones</a> (in recently completed order)

* 0.3.1 - Small fixes.

Added continuous integration settings, missing database tables (for policies), added planned
milestones, fix indentation in composer.json
* 0.3 - Prepare for upload to Github. Estimate 1 day. DONE - 2019-03-12

The system should present a basic styled POC (proof-of-concept) website with
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ parameters:
level: 7
ignore_patterns: ['web','database','docker','cache','logs','.phpstorm.meta.php','NotFoundHandler.php']
phpversion:
project: '7.3'
project: '7.2'
phpunit:
config_file: ./qaTools/phpunit.xml
securitychecker: ~
Expand Down
16 changes: 15 additions & 1 deletion src/Web/Controllers/DebugBarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@
*/
class DebugBarController
{

/**
* @var DebuggerProviderInterface $debuggerProvider
*/
private $debuggerProvider;
/**
* @var LoggerInterface $logger
*/
private $logger;
/**
* @var CacheProvider $cacheProvider
*/
private $cacheProvider;

/**
* DebugBarController constructor.
* @param DebuggerProviderInterface $debuggerProvider
* @param LoggerInterface $logger
* @param CacheProvider $cacheProvider
*/
public function __construct(
DebuggerProviderInterface $debuggerProvider,
LoggerInterface $logger,
Expand Down

0 comments on commit fbf50c1

Please sign in to comment.