Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Exporter #32

Merged
merged 87 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f9e741b
Create new module Export
that-guy-iain Oct 31, 2022
d9812cd
Rename normaliser
that-guy-iain Oct 31, 2022
f0e09dd
Define engine interface
that-guy-iain Nov 1, 2022
aa8039a
Change export response to an interface
that-guy-iain Nov 1, 2022
d32e51d
Add supports to Normaliser
that-guy-iain Nov 1, 2022
4ebf24c
Add normaliser manager interfacew
that-guy-iain Nov 1, 2022
5633f73
Add download response
that-guy-iain Nov 2, 2022
b42745b
Add exporter manager
that-guy-iain Nov 2, 2022
a710022
Add direct download engine test
that-guy-iain Nov 2, 2022
e140cee
Add invalid data provider exception
that-guy-iain Nov 2, 2022
7dbd34c
Add invalid data provider exception test
that-guy-iain Nov 2, 2022
affcc1f
Add export configuration class
that-guy-iain Nov 2, 2022
17ec6f2
Add export.enable configu
that-guy-iain Nov 2, 2022
87b30ca
Update depfile.yaml to add Export
that-guy-iain Nov 17, 2022
01fe32f
Update depfile.yaml to add Export in ruleset too
that-guy-iain Nov 17, 2022
0f535a3
athena
that-guy-iain Nov 18, 2022
6cc012d
athena security
that-guy-iain Nov 18, 2022
9083b0f
Add basic services file for export
that-guy-iain Nov 18, 2022
3dd0018
Add basic services file for export to module configuration
that-guy-iain Nov 18, 2022
010b9fc
Add twig UI for export
that-guy-iain Nov 19, 2022
7cbfc3c
WIP exporator code for Athena export
that-guy-iain Nov 19, 2022
59c542f
WIP exporator code for Athena export
that-guy-iain Nov 20, 2022
2945eaa
Add code stle
that-guy-iain Nov 20, 2022
8650869
athena revert
that-guy-iain Nov 20, 2022
3b526af
athena revert test
that-guy-iain Nov 20, 2022
d6fd738
athena revert routing test
that-guy-iain Nov 20, 2022
52704ca
WIP
that-guy-iain Nov 21, 2022
5709af6
WIP test
that-guy-iain Nov 21, 2022
1c8759b
WIP add deafault athena normaliser
that-guy-iain Nov 22, 2022
39fe686
Fix all export
that-guy-iain Nov 22, 2022
7fa6c09
Add webprofile files
that-guy-iain Nov 22, 2022
2d716be
Add if statements to hide export if not enabled for athena section
that-guy-iain Nov 23, 2022
b6710d2
Add translations for Athena
that-guy-iain Nov 23, 2022
af3239f
WIP explore new data provider method
that-guy-iain Nov 23, 2022
e26730f
Refactor to user DefaultDataProvider
that-guy-iain Nov 24, 2022
b979efb
Make dataproviders public services in compiler pass
that-guy-iain Nov 24, 2022
74aa0e0
Refactor noramlisers
that-guy-iain Nov 24, 2022
facf97e
Add comment
that-guy-iain Nov 24, 2022
c54fb49
Fix build
that-guy-iain Nov 24, 2022
c745a39
Fix build
that-guy-iain Nov 24, 2022
45795cb
Fix tests
that-guy-iain Nov 24, 2022
15d0ded
Add entity&repository
that-guy-iain Nov 25, 2022
33e563f
Fix mongodb config
that-guy-iain Nov 25, 2022
2d680c2
Fix orm config
that-guy-iain Nov 25, 2022
96f9092
Update tests
that-guy-iain Nov 25, 2022
2b67e00
Placeholder files
that-guy-iain Nov 26, 2022
08490fa
WIP placeholders
that-guy-iain Nov 26, 2022
062fb19
Add saving BackgroundExportRequest
that-guy-iain Nov 27, 2022
8780703
Add uploadString
that-guy-iain Nov 27, 2022
0b3af8a
Add file path
that-guy-iain Nov 27, 2022
606e3c0
Tweak BackgroundRequestHandler
that-guy-iain Nov 28, 2022
c6ed3fa
WIP email handler
that-guy-iain Nov 28, 2022
e37c605
Update log messages
that-guy-iain Nov 28, 2022
63aeecb
WIP add services
that-guy-iain Nov 29, 2022
18bbfcf
Tweak to Athena to handle background requests
that-guy-iain Dec 1, 2022
49101ff
Add redirect to Athena page
that-guy-iain Dec 2, 2022
654f805
Background download engine
that-guy-iain Dec 2, 2022
f06bb4f
Messenger
that-guy-iain Dec 2, 2022
1254f37
Add athena translations
that-guy-iain Dec 3, 2022
876f2b0
Add configuration for default engine
that-guy-iain Dec 3, 2022
7011112
Add configuration for user provider
that-guy-iain Dec 3, 2022
2263144
Add unsupported response type exception
that-guy-iain Dec 3, 2022
b8a0e51
Add Default data provider tests
that-guy-iain Dec 3, 2022
e078faa
Add create query builder method to Doctrine repository
that-guy-iain Dec 3, 2022
d8ebbc5
Add test for data provider fetcher
that-guy-iain Dec 3, 2022
5a52303
Add test for background email engine
that-guy-iain Dec 3, 2022
89e8e1a
Add test for background download engine
that-guy-iain Dec 3, 2022
b44deb9
Add test for background email request handler
that-guy-iain Dec 3, 2022
a76fafc
Add final
that-guy-iain Dec 3, 2022
cb4984b
Add background download request handler
that-guy-iain Dec 4, 2022
4d44565
Add a final
that-guy-iain Dec 4, 2022
6ab1f89
Add test normaliser manager
that-guy-iain Dec 4, 2022
f8b9176
Add test email factory
that-guy-iain Dec 4, 2022
e31a5e9
Remove final
that-guy-iain Dec 4, 2022
c040f58
Start normaliser building for Athena
that-guy-iain Dec 4, 2022
1d5c041
Improve normaliser
that-guy-iain Dec 4, 2022
6d8a021
Add normalisers from Athena sections
that-guy-iain Dec 4, 2022
014d18a
Remove depenendecy on NormaliserInteface from SectionInterface
that-guy-iain Dec 8, 2022
8e333eb
Add fluid interface
that-guy-iain Dec 8, 2022
ee67ecd
Fix download
that-guy-iain Dec 8, 2022
1cbf355
Add excel exporter
that-guy-iain Dec 8, 2022
3af087f
Add log messages to engines
that-guy-iain Dec 8, 2022
3fd9445
Add log messages to handlers
that-guy-iain Dec 8, 2022
3acd59d
Add behat test for athena export
that-guy-iain Dec 8, 2022
2490d19
Add export failed exception
that-guy-iain Dec 8, 2022
38d1799
Fix test
that-guy-iain Dec 8, 2022
462ae00
Remove todo comment
that-guy-iain Dec 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ REDIS_HOST="localhost"

APPLICATION_URL="http://localhost"

ATHENA_HOST="athena.local"

STRIPE_PRIVATE_API_KEY=""
STRIPE_PUBLIC_API_KEY=""
STRIPE_WEBHOOK_SECRET=""
Expand Down Expand Up @@ -64,4 +66,11 @@ ELASTICSEARCH_HOST='http://elasticsearch:9200'


TENANT_HOSTNAME=ha-local.xyz
TENANT_DEFAULT_DATABASE=parthenon
TENANT_DEFAULT_DATABASE=parthenon

AWS_S3_KEY=
AWS_S3_SECRET=
AWS_S3_REGION=
AWS_S3_ENDPOINT=
AWS_S3_BUCKET=
UPLOAD_ACCESS_URL=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/docker/logs/
/docker/database/data/
/docker/timescaledb/data/
.idea
.php_cs.cache

Expand All @@ -28,7 +29,6 @@ yarn-error.log

composer.lock
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"monolog/monolog": "^2.8",
"nyholm/psr7": "^1.5",
"parthenon/transaction-cloud": "^0.1.0",
"phpoffice/phpspreadsheet": "^1.25",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0",
"ramsey/uuid": "^4.5.1",
Expand All @@ -32,9 +33,10 @@
"symfony/expression-language": "^6.1",
"symfony/flex": "^1.19",
"symfony/form": "^6.1",
"symfony/framework-bundle": "^6.1",
"symfony/framework-bundle": "^6.1.7",
"symfony/mailer": "6.*",
"symfony/monolog-bundle": "^3.8",
"symfony/redis-messenger": "6.1.*",
"symfony/security-bundle": "^6.1",
"symfony/translation": "^6.1",
"symfony/twig-bundle": "^6.1",
Expand Down Expand Up @@ -72,7 +74,8 @@
"symfony/messenger": "^6.1",
"symfony/phpunit-bridge": "^6.1",
"toin0u/digitalocean-v2": "^4.5",
"wildbit/postmark-php": "^4.0"
"wildbit/postmark-php": "^4.0",
"symfony/web-profiler-bundle": "^6.1.6"
},
"config": {
"optimize-autoloader": true,
Expand Down Expand Up @@ -122,7 +125,7 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "6.*"
"require": "6.1.*"
}
}
}
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
];
20 changes: 11 additions & 9 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ framework:

transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
#sync: 'sync://'

routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
'Parthenon\Export\BackgroundEmailExportRequest': async
'Parthenon\Export\Entity\BackgroundExportRequest': async

# when@test:
# framework:
# messenger:
# transports:
# # replace with your transport name here (e.g., my_transport: 'in-memory://')
# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
# async: 'in-memory://'
when@test:
framework:
messenger:
transports:
# replace with your transport name here (e.g., my_transport: 'in-memory://')
# For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
async: 'in-memory://'
17 changes: 15 additions & 2 deletions config/packages/pathenon.yaml → config/packages/parthenon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ parthenon:
orm_entity_manager: tenant
default_database: '%env(resolve:TENANT_DEFAULT_DATABASE)%'
common:
uploader:
default:
provider: s3
naming_strategy: random_time
url: '%env(resolve:UPLOAD_ACCESS_URL)%'
s3:
key: '%env(resolve:AWS_S3_KEY)%'
secret: '%env(resolve:AWS_S3_SECRET)%'
region: '%env(resolve:AWS_S3_REGION)%'
endpoint: '%env(resolve:AWS_S3_ENDPOINT)%'
bucket_name: '%env(resolve:AWS_S3_BUCKET)%'
visibility: public
elasticsearch:
connection_type: 'normal'
hosts: ['%env(resolve:ELASTICSEARCH_HOST)%']
Expand All @@ -80,7 +92,6 @@ parthenon:
provider: sendgrid
sendgrid:
api_key: '%env(resolve:SENDGRID_API_KEY)%'

athena:
enabled: true
payments:
Expand Down Expand Up @@ -133,4 +144,6 @@ parthenon:
limit:
team_invite:
limit: 5
description: "Number of users"
description: "Number of users"
export:
enabled: true
17 changes: 17 additions & 0 deletions config/packages/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
when@dev:
web_profiler:
toolbar: true
intercept_redirects: false

framework:
profiler:
only_exceptions: false
collect_serializer_data: true

when@test:
web_profiler:
toolbar: false
intercept_redirects: false

framework:
profiler: { collect: false }
5 changes: 1 addition & 4 deletions config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#index:
# path: /
# controller: App\Controller\DefaultController::index
app_backoffice:
resource: .
type: athena
# controller: App\Controller\DefaultController::index
4 changes: 4 additions & 0 deletions config/routes/annotations.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
app_backoffice:
resource: .
type: athena

controllers:
resource: ../../src/Controller/
type: annotation
Expand Down
8 changes: 8 additions & 0 deletions config/routes/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt

web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
10 changes: 10 additions & 0 deletions create-public-edition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rm -Rf ../public-edition/src/AbTesting/*
rm -Rf ../public-edition/src/Athena/*
rm -Rf ../public-edition/src/Common/*
rm -Rf ../public-edition/src/Funnel/*
rm -Rf ../public-edition/src/Export/*
rm -Rf ../public-edition/src/Health/*
rm -Rf ../public-edition/src/Invoice/*
rm -Rf ../public-edition/src/Notification/*
Expand Down Expand Up @@ -60,6 +61,15 @@ cp -R src/Parthenon/Cloud ../public-edition/src/
cp src/Parthenon/DependencyInjection/Modules/Cloud.php ../public-edition/src/DependencyInjection/Modules/Cloud.php
cp -R src/Parthenon/Resources/config/services/cloud.xml ../public-edition/src/Resources/config/services/cloud.xml

echo "[x] Update Export"
cp -R src/Parthenon/Export ../public-edition/src/
cp src/Parthenon/DependencyInjection/Modules/Export.php ../public-edition/src/DependencyInjection/Modules/Export.php
cp -R src/Parthenon/Resources/config/doctrine-mapping/Export ../public-edition/src/Resources/config/doctrine-mapping/Export
cp -R src/Parthenon/Resources/config/services/orm/export.xml ../public-edition/src/Resources/config/services/orm/export.xml
cp -R src/Parthenon/Resources/config/services/odm/export.xml ../public-edition/src/Resources/config/services/odm/export.xml
cp -R src/Parthenon/Resources/config/services/export.xml ../public-edition/src/Resources/config/services/export.xml
cp -R tests/Parthenon/Export ../public-edition/tests/Parthenon/

echo "[x] Update Funnel"
cp -R src/Parthenon/Funnel ../public-edition/src/
cp src/Parthenon/DependencyInjection/Modules/Funnel.php ../public-edition/src/DependencyInjection/Modules/Funnel.php
Expand Down
8 changes: 8 additions & 0 deletions depfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ layers:
collectors:
- type: directory
regex: src/Parthenon/Common/*
- name: Export
collectors:
- type: directory
regex: src/Parthenon/Export/*
- name: User
collectors:
- type: directory
Expand Down Expand Up @@ -54,6 +58,7 @@ ruleset:
- Athena
Athena:
- Common
- Export
User:
- Common
- Notification
Expand All @@ -66,4 +71,7 @@ ruleset:
- Common
Invoice:
- Common
Export:
- Common
- Notification
Common:
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- parthenon

redis:
image: redis:4-alpine
image: redis:5-alpine
networks:
- parthenon
ports:
Expand Down
Empty file.
34 changes: 34 additions & 0 deletions migrations/Version20221202162512.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221202162512 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE parthenon_export_background_export_requests (id UUID NOT NULL, exported_file VARCHAR(255) DEFAULT NULL, exported_file_path VARCHAR(255) DEFAULT NULL, export_format VARCHAR(255) NOT NULL, filename VARCHAR(255) NOT NULL, data_provider_service VARCHAR(255) NOT NULL, parameters TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN parthenon_export_background_export_requests.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN parthenon_export_background_export_requests.parameters IS \'(DC2Type:array)\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP TABLE parthenon_export_background_export_requests');
}
}
6 changes: 6 additions & 0 deletions src/Parthenon/Athena/AbstractSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Parthenon\Athena;

use Parthenon\Athena\Export\NormaliserBuilderInterface;
use Parthenon\Athena\Filters\ListFilters;

abstract class AbstractSection implements SectionInterface
Expand Down Expand Up @@ -82,4 +83,9 @@ public function getButtons(): array
{
return [];
}

public function buildNormalsier(NormaliserBuilderInterface $builder): NormaliserBuilderInterface
{
return $builder;
}
}
14 changes: 14 additions & 0 deletions src/Parthenon/Athena/Compiler/AthenaCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

use Parthenon\Athena\AccessRightsManagerInterface;
use Parthenon\Athena\Crud\CrudController;
use Parthenon\Athena\Export\NormaliserFactoryInterface;
use Parthenon\Athena\Filters\FilterManager;
use Parthenon\Athena\ViewTypeManager;
use Parthenon\Export\Normaliser\NormaliserInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -39,6 +41,10 @@ public function process(ContainerBuilder $container)
$this->handleViewTypes($container);
}

public function handleSectionNormalisers(ContainerBuilder $containerBuilder): void
{
}

private function handleViewTypes(ContainerBuilder $container): void
{
$viewTypeManager = $container->getDefinition('parthenon.athena.view_type_manager');
Expand Down Expand Up @@ -150,6 +156,14 @@ private function processSectionDefinitions(ContainerBuilder $container, array $d
$controllerDefinition->setAutowired(true);

$container->setDefinition('athena_controller_'.$servicePart, $controllerDefinition);

$normaliserDefinition = new Definition();
$normaliserDefinition->setClass(NormaliserInterface::class);
$normaliserDefinition->setFactory([new Reference(NormaliserFactoryInterface::class), 'build']);
$normaliserDefinition->setArgument('$section', new Reference($name));
$normaliserDefinition->addTag('parthenon.export.normaliser');

$container->setDefinition('athena_export_normaliser_'.$servicePart, $normaliserDefinition);
}
}

Expand Down
53 changes: 53 additions & 0 deletions src/Parthenon/Athena/Controller/ExportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

/*
* Copyright Iain Cambridge 2020-2022.
*
* Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
*
* Change Date: TBD ( 3 years after 2.1.0 release )
*
* On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
*/

namespace Parthenon\Athena\Controller;

use Parthenon\Export\Entity\BackgroundExportRequest;
use Parthenon\Export\Repository\BackgroundExportRequestRepositoryInterface;
use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;

class ExportController
{
#[Template('@Parthenon/athena/crud/export_background_email.html.twig')]
public function emailWaiting(LoggerInterface $logger)
{
$logger->info("An Athena user has been told they'll receive an email");

return [];
}

public function downloadWaiting(Request $request, LoggerInterface $logger, BackgroundExportRequestRepositoryInterface $backgroundExportRequestRepository, Environment $twig)
{
$logger->info('An Athena user has checked the process of an export');

$id = $request->get('id');

/** @var BackgroundExportRequest $backgroundExportRequest */
$backgroundExportRequest = $backgroundExportRequestRepository->findById($id);

$downloadUrl = $backgroundExportRequest->getExportedFilePath();

if ($downloadUrl) {
return new RedirectResponse($downloadUrl);
} else {
return new Response($twig->render('@Parthenon/athena/crud/export_background_download.html.twig'));
}
}
}