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

Ajout des pourcentages sur les données filtrées #299

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/CompanySizeReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function execute()
->addSelect('COUNT(response.id) as nbResponse')
->addGroupBy('response.companySize');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/CompanyTypeReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function execute()
->addSelect('COUNT(response.id) as nbResponse')
->addGroupBy('response.companyType');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/ExperienceSalaryReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function execute()
->setParameter(':minResult', $this->minResult)
->groupBy('response.experience');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/GenderReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function execute()
->groupBy('response.gender')
->orderBy('nbResponse', 'desc');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/JobTitleReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function execute()
->addSelect('COUNT(response.id) as nbResponse')
->addGroupBy('response.jobTitle');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/PhpVersionReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function execute()
->setParameter(':minResult', $this->minResult)
->groupBy('response.phpVersion');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Afup/Barometre/Report/RemoteUsageReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function execute()
->orderBy('nbResponse', 'desc');

$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Afup/Barometre/Report/SalaryReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function execute()
foreach ($this->queryBuilder->execute() as $row) {
$slice = $row['salarySlice'];
$results[$slice] = array(
'count' => $row['nbResponse']
'count' => $row['nbResponse'],
'nbResponse' => $row['nbResponse'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ne serait-il pas possible de mutualiser le count et le nbResponse ? les deux contiennent la même information.
Plusieurs solutions je pense :

  • soit renommer count en nbResponse et modifier les fichiers utilisant le count
  • soit modifier la méthode addPercentResponse pour qu'elle prenne en paramètre facultatif le nom du champ à prendre en compte pour le calcul (par défaut nbResponse). Et dans tout cas, tu passe comme nom count.

Qu'en penses-tu ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui tout à fait. Je n'ai pas voulu le faire dans cette PR et risquer de casser quelque chose que je n'aurai pas vu, mais l'intégrer dans une autre.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tu ne le fais pas maintenant tu ne le feras jamais je pense. Si tu as peur de la régression, tu peux très bien le faire dans un commit séparé ce qui permettrait de faire un revert facilement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK corrigé dans le dernier commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juste pour valider, ligne 36 à 38 on déclare un tableau baseResult avec comme clé count qui sert dans certains cas à remplir un autre tableau baseResults. Cette clé count était-elle fonctionnellement différente de la clé que tu as supprimée ?. Car dans certains cas, on fait un array_fill avec ce baseResult qu'on merge ensuite ligne 50 dans results.

N'aurait-on donc pas dans certains cas un tableau results qui contient pour certains clés un count et dans d'autres cas un nbResponse ?

);
}

Expand Down Expand Up @@ -56,6 +57,7 @@ public function execute()
}

$this->data = $results;
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/SalarySatisfactionReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function execute()
->groupBy('response.salarySatisfaction')
->orderBy('salarySatisfaction', 'desc');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/SpecialityReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function execute()
->addGroupBy('specialityName')
->addOrderBy('nbResponse', 'desc');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Afup/Barometre/Report/StatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function execute()
->addSelect('COUNT(response.id) as nbResponse')
->addGroupBy('response.status');

$this->data = $this->queryBuilder->execute();
$this->data = $this->queryBuilder->execute()->fetchAll();
$this->data = $this->addPercentResponse($this->data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<tr>
<th>{{ 'report.view.company_size' | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.companySize|enum_label('company_size') }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<tr>
<th>{{ "report.view.company_type" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.companyType|enum_label('company_type') }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<tr>
<th>{{ 'report.view.experience' | trans }}</th>
<th>{{ "report.view.annual_salary" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.experience|enum_label('experience') }}</td>
<td class="text-right">{{ row.annualSalary|round(-2)|number_format_decimal }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<tr>
<th>{{ "report.gender.label" | trans }}</th>
<th class="text-right">{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
<th data-graph-skip="1" class="text-right">{{ "report.view.average_salary" | trans }}</th>
</tr>
</thead>
Expand All @@ -29,6 +30,7 @@
{{ row.gender|enum_label('gender') }}
</td>
<td {% if row.gender is null %}data-graph-item-highlight="1"{% endif %} {% if icons[row.gender|enum_label('gender')].color %}data-graph-item-color="{{ icons[row.gender|enum_label('gender')].color }}"{% endif %} data-graph-name='{{ row.gender|enum_label('gender') }}' class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
<td class="text-right">{{ row.averageSalary|number_format(null, '', ' ') }}</td>
</tr>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<tr>
<th>{{ "report.view.job_title" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.jobTitle|enum_label('job_title') }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<tr>
<th>{{ "report.view.php_version" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
Expand All @@ -22,6 +23,7 @@
data-graph-name="{{ row.phpVersion|enum_label('php_version') }}"
class="text-right">{{ row.nbResponse }}
</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<tr>
<th>{{ "report.view.remote_usage" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu parlais d'alignement, ça peux être intéressant d'aligner ces pourcentages à droite

</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.remoteUsage|enum_label('remote_usage') }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<tr>
<th>{{ "report.view.gross_annual_salary" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
Expand All @@ -19,6 +20,7 @@
{{ row.salarySliceTo|number_format }}
</td>
<td class="text-right">{{ row.count }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<tr>
<th>{{ "report.view.salary_satisfaction" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
Expand All @@ -30,6 +31,7 @@
{{ row.salarySatisfaction|enum_label('salary_satisfaction') }}
</td>
<td {% if row.salarySatisfaction == 3 %}data-graph-item-highlight="1"{% endif %} {% if icons[row.salarySatisfaction|enum_label('salary_satisfaction')].color %}data-graph-item-color="{{ icons[row.salarySatisfaction|enum_label('salary_satisfaction')].color }}"{% endif %} data-graph-name='{{ row.salarySatisfaction|enum_label('salary_satisfaction') }}' class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
<tr>
<th>{{ "report.view.speciality" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
{% for row in results %}
<tr>
<td>{{ row.specialityName }}</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<tr>
<th>{{ "report.view.status" | trans }}</th>
<th>{{ "report.view.response_number" | trans }}</th>
<th>{{ "report.view.response_percent" | trans }}</th>
</tr>
</thead>
<tbody>
Expand All @@ -15,6 +16,7 @@
{{ row.status|enum_label('status') }}
</td>
<td class="text-right">{{ row.nbResponse }}</td>
<td>{{ row.percentResponse|round(2) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down