diff --git a/validata_ui/templates/validation_macros.html b/validata_ui/templates/validation_macros.html index 714ea396eb08e9b472503c6ee5b1bdbb4e47a301..97e78bd86106d14ee40de84c086678536750ffff 100644 --- a/validata_ui/templates/validation_macros.html +++ b/validata_ui/templates/validation_macros.html @@ -70,10 +70,10 @@ {% macro error_statistics(report) %} {% set structure_errors = report.table['error-stats']['structure-errors'] %} -{% if structure_errors['nb'] != 0 %} -Erreur(s) de structure ({{ structure_errors['nb'] }}) : +{% if structure_errors['count'] != 0 %} +Erreur(s) de structure ({{ structure_errors['count'] }}) :
{{ report.table['error-stats']['total'] }} erreur(s) détectée(s).
+{{ report.table['error-stats']['count'] }} erreur(s) détectée(s).
{{ macros.error_statistics(report) }} diff --git a/validata_ui/views.py b/validata_ui/views.py index 530e5e2667974a2134c3917bafd7e2af778b2783..478eb5b412eb8cd3e5e5598adc454d299e84d364 100644 --- a/validata_ui/views.py +++ b/validata_ui/views.py @@ -8,6 +8,7 @@ import subprocess import time from datetime import datetime from io import BytesIO +from operator import itemgetter from pathlib import Path from urllib.parse import quote_plus @@ -15,7 +16,7 @@ from commonmark import commonmark from flask import make_response, redirect, render_template, request, url_for import tabulator -from validata_core import csv_helpers +from validata_core import csv_helpers, messages from validata_core.loaders import custom_loaders from validata_ui import app from validata_ui.ui_util import flash_error, flash_warning @@ -133,7 +134,7 @@ def create_validata_report(goodtables_report, schema): # Then group them in 2 groups : structure and body report['table']['errors'] = {'structure': [], 'body': []} for err in errors: - if err['context'] != 'body': + if err['tag'] == 'structure': report['table']['errors']['structure'].append(err) else: report['table']['errors']['body'].append(err) @@ -164,6 +165,15 @@ def create_validata_report(goodtables_report, schema): rows[-1]['errors']['row'] = err report['table']['errors']['body_by_rows'] = rows + # Sort by error names in statistics + stats = report['table']['error-stats'] + code_title_map = messages.ERROR_MESSAGE_DEFAULT_TITLE + for key in ('structure-errors', 'value-errors'): + # convert dict into tuples with french title instead of error code + # and sorts by title + stats[key]['count-by-code'] = sorted([(code_title_map.get(k, k), v) for k, v in stats[key]['count-by-code'].items()], + key=itemgetter(0)) + return report