Skip to content

Commit

Permalink
Merge branch 'import-2023' into preprod
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitLeveque committed Jan 20, 2024
2 parents 9e29484 + 682e41b commit cb57d0b
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ services:
parent: App\Report\AbstractReport
tags: ['barometre.report']

App\Report\AgeReport:
parent: App\Report\AbstractReport
tags: ['barometre.report']

App\Report\RetrainingReport:
parent: App\Report\AbstractReport
tags: ['barometre.report']
calls:
- setChildReports: [ [ '@App\Report\RetrainingEvolutionReport' ] ]

App\Report\SpecialitySalaryReport:
parent: App\Report\AbstractReport
tags: ['barometre.report']
Expand All @@ -205,6 +215,9 @@ services:
App\Report\PhpVersionEvolutionReport:
parent: App\Report\AbstractDistributionEvolutionReport

App\Report\RetrainingEvolutionReport:
parent: App\Report\AbstractDistributionEvolutionReport

App\Report\PhpVersionReport:
parent: App\Report\AbstractReport
calls:
Expand Down
96 changes: 96 additions & 0 deletions src/Filter/AgeFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

declare(strict_types=1);

namespace App\Filter;

use App\Form\Type\AgeFilterType;
use Doctrine\DBAL\Query\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;

/**
* Filter on Age Min & max.
*/
class AgeFilter implements FilterInterface
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('age', AgeFilterType::class, [
'label' => 'filter.age',
]);
}

/**
* {@inheritdoc}
*/
public function buildQuery(QueryBuilder $queryBuilder, array $values = [])
{
if (!\array_key_exists('age', $values)) {
return;
}

// Switch min and max age if user has inverted the fields
if (isset($values['age']['min'])
&& isset($values['age']['max'])
&& $values['age']['max'] < $values['age']['min']
) {
list($values['age']['min'], $values['age']['max']) =
[$values['age']['max'], $values['age']['min']];
}

if (isset($values['age']['min'])) {
$queryBuilder
->andWhere('response.age >= :minAge')
->setParameter('minAge', $values['age']['min']);
}

if (isset($values['age']['max'])) {
$queryBuilder
->andWhere('response.age <= :maxAge')
->setParameter('maxAge', $values['age']['max']);
}
}

/**
* {@inheritdoc}
*/
public function convertValuesToLabels($value)
{
// Switch min and max if user has inverted the fields
if (isset($value['min']) && isset($value['max']) && $value['max'] < $value['min']) {
list($value['max'], $value['min']) = [$value['min'], $value['max']];
}

$labels = [];
if (isset($value['min'])) {
$labels['min'] = '>= '.$value['min'].' ans';
}

if (isset($value['max'])) {
$labels['max'] = '<= '.$value['max'].' ans';
}

return $labels;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'age';
}

/**
* Filter weight.
*
* @return int
*/
public function getWeight()
{
return 11;
}
}
34 changes: 34 additions & 0 deletions src/Form/Type/AgeFilterType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace App\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* Age Filter Type.
*/
class AgeFilterType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('min', IntegerType::class, ['required' => false, 'attr' => ['placeholder' => 'filter.age.min']])
->add('max', IntegerType::class, ['required' => false, 'attr' => ['placeholder' => 'filter.age.max']])
;
}

/**
* {@inheritdoc}
*/
public function getBlockPrefix(): string
{
return 'age';
}
}
4 changes: 4 additions & 0 deletions src/Report/AbstractExperienceReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function execute()
];
}

if (null === $this->data) {
$this->data = [];
}

uasort($this->data, static function (array $experienceA, array $experienceB): int {
return $experienceA['experience'] <=> $experienceB['experience'];
});
Expand Down
30 changes: 30 additions & 0 deletions src/Report/AgeReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace App\Report;

class AgeReport extends AbstractReport
{
/**
* {@inheritdoc}
*/
public function execute()
{
$this->queryBuilder
->select('response.age as age')
->addSelect('COUNT(response.id) as nbResponse')
->andWhere('response.age > 0')
->addGroupBy('response.age');

$this->data = $this->queryBuilder->fetchAllAssociative();
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'age';
}
}
24 changes: 24 additions & 0 deletions src/Report/RetrainingEvolutionReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Report;

class RetrainingEvolutionReport extends AbstractDistributionEvolutionReport
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'retraining_evolution';
}

/**
* {@inheritdoc}
*/
protected function getFieldName()
{
return 'retraining';
}
}
29 changes: 29 additions & 0 deletions src/Report/RetrainingReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace App\Report;

class RetrainingReport extends AbstractReport
{
/**
* {@inheritdoc}
*/
public function execute()
{
$this->queryBuilder
->select('response.retraining as retraining')
->addSelect('COUNT(response.id) as nbResponse')
->addGroupBy('response.retraining');

$this->data = $this->queryBuilder->fetchAllAssociative();
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'retraining';
}
}
7 changes: 7 additions & 0 deletions templates/Filters/theme.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
</div>
{% endblock %}

{% block age_widget %}
<div class="row">
<div class="col-md-6">{{ form_widget(form.min) }}</div>
<div class="col-md-6">{{ form_widget(form.max) }}</div>
</div>
{% endblock %}


{% block salary_row %}
<div class="form-group">
Expand Down
19 changes: 19 additions & 0 deletions templates/Report/age.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<table class="table table-striped highchart tablesorter"
data-graph-container-before="1"
data-graph-type="column"
data-graph-legend-disabled="1">
<thead>
<tr>
<th>{{ 'report.view.age' | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.age }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
</tr>
{% endfor %}
</tbody>
</table>
21 changes: 21 additions & 0 deletions templates/Report/retraining.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<table class="table table-striped highchart tablesorter"
data-graph-container-before="1"
data-graph-type="column"
data-graph-legend-disabled="1">
<thead>
<tr>
<th>{{ "report.view.retraining" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>
{{ row.retraining|enum_label('App\\Enums\\RetrainingEnums') }}
</td>
<td class="text-right">{{ row.nbResponse }}</td>
</tr>
{% endfor %}
</tbody>
</table>
14 changes: 14 additions & 0 deletions templates/Report/retraining_evolution.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% set color = {
(constant('App\\Enums\\RetrainingEnums::YES_SHORT')):'#3D96AE',
(constant('App\\Enums\\RetrainingEnums::YES_LONG')):'#89A54E',
(constant('App\\Enums\\RetrainingEnums::YES_WITHOUT_TRAINING')):'#80699B',
(constant('App\\Enums\\RetrainingEnums::NO')):'#4C6EAF',
}
%}

{% set fieldName = 'App\\Enums\\RetrainingEnums' %}
{% set title = 'Année' %}

{% block report_content %}
{% include 'Report/_distribution_evolution_report.html.twig' with {'color': color, 'fieldName': fieldName} %}
{% endblock %}
32 changes: 32 additions & 0 deletions translations/messages.fr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
<source>filter.salary.max</source>
<target>Maximum</target>
</trans-unit>
<trans-unit id="filter.age">
<source>filter.age</source>
<target>Age</target>
</trans-unit>
<trans-unit id="filter.age.min">
<source>filter.age.min</source>
<target>Minimum</target>
</trans-unit>
<trans-unit id="filter.age.max">
<source>filter.age.max</source>
<target>Maximum</target>
</trans-unit>
<trans-unit id="filter.certification">
<source>filter.certification</source>
<target>Certifications</target>
Expand Down Expand Up @@ -142,6 +154,14 @@
<source>report.view.job_title</source>
<target>Initulé de poste</target>
</trans-unit>
<trans-unit id="report.view.age">
<source>report.view.age</source>
<target>Âge</target>
</trans-unit>
<trans-unit id="report.view.retraining">
<source>report.view.retraining</source>
<target>Venez-vous d'une reconversion ?</target>
</trans-unit>
<trans-unit id="report.status.label">
<source>report.status.label</source>
<target>Distribution des statuts</target>
Expand All @@ -154,6 +174,18 @@
<source>report.salary.label</source>
<target>Distribution des salaires</target>
</trans-unit>
<trans-unit id="report.age.label">
<source>report.age.label</source>
<target>Distribution de l'âge des répondants</target>
</trans-unit>
<trans-unit id="report.retraining.label">
<source>report.retraining.label</source>
<target>Venez-vous d'une reconversion ?</target>
</trans-unit>
<trans-unit id="report.retraining_evolution.label">
<source>report.retraining_evolution.label</source>
<target>Évolution de la distribution des reconversion</target>
</trans-unit>
<trans-unit id="report.salary_evolution.label">
<source>report.salary_evolution.label</source>
<target>Évolution des salaires</target>
Expand Down

0 comments on commit cb57d0b

Please sign in to comment.