Commit 27e27e6c authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Statistics adjustments

parent 62148385
......@@ -166,7 +166,7 @@ a,b,c,x,y"""
report = validate_csv_text(source=source, schema=schema_abc)
assert report['tables'][0]['error-count'] == 1
assert len(report['tables'][0]['errors']) == 1
assert report['tables'][0]['error-stats']['total'] == 2
assert report['tables'][0]['error-stats']['count'] == 2
assert report['tables'][0]['errors'][0]['code'] == 'extra-headers'
assert report['tables'][0]['errors'][0]['message-data']['headers'] == ['X', 'Y']
......
......@@ -69,20 +69,20 @@ def improve_messages(report, schema):
def compute_error_statistics(errors):
"""Computes error statistics as a dict:
{
'total': 123, # Total nb of errors
'count': 12,
'structure-errors': {
'nb': 3, # Structure errors nb
'distribution': [
['foobar', 2],
['baz', 1]
]
'count': 1,
'count-by-code': {
'invalid-column-delimiter': 1
}
},
'value-errors': {
'nb': 2, # Value errors nb
'distribution': [
['bar', 1],
['buz', 119]
]
'count': 10,
'count-by-code': {
'type-or-format-error': 2,
'pattern-constraint': 7,
'french-siret-value': 1,
}
}
}
"""
......@@ -99,19 +99,19 @@ def compute_error_statistics(errors):
errors_nb = len(err['message-data']['headers']) \
if err['code'] in ('extra-headers', 'missing-headers') else 1
errors_nb_dict[err_tag] += errors_nb
errors_dist_dict[err_tag][err['title']] += errors_nb
errors_dist_dict[err_tag][err['code']] += errors_nb
# Compute statistics
return {
'structure-errors': {
'nb': errors_nb_dict['structure'],
'distribution': list(errors_dist_dict['structure'].items()),
'count': errors_nb_dict['structure'],
'count-by-code': errors_dist_dict['structure'],
},
'value-errors': {
'nb': errors_nb_dict['value'],
'distribution': list(errors_dist_dict['value'].items()),
'count': errors_nb_dict['value'],
'count-by-code': errors_dist_dict['value'],
},
'total': errors_nb_dict['structure'] + errors_nb_dict['value']
'count': errors_nb_dict['structure'] + errors_nb_dict['value']
}
......
......@@ -302,3 +302,42 @@ ERROR_MESSAGE_FUNC = {
'french-siret-value': french_siret_value,
'compare-columns-value': compare_columns_value,
}
ERROR_MESSAGE_DEFAULT_TITLE = {
# Core checks
'blank-header': 'colonne sans en-tête',
'blank-row': 'ligne vide',
'duplicate-header': 'en-tête répétée',
'duplicate-row': 'ligne dupliquée',
'enumerable-constraint': 'valeur incorrecte',
'maximum-constraint': 'valeur maximale non respectée',
'maximum-length-constraint': 'longueur maximale non respectée',
'minimum-constraint': 'valeur minimale non respectée',
'minimum-length-constraint': 'longueur minimale non respectée',
# These 3 errors are skipped
# - non-matching-header
# - extra-header
# - missing-header
# and replaced by 3 aggregated errors:
# - missing-headers
# - extra-headers
# - wrong-headers-order
# missing-value
'pattern-constraint': 'erreur de format',
'required-constraint': 'valeur requise',
'type-or-format-error': 'format incorrect',
'unique-constraint': 'doublons',
# Validata pre-checks
'extra-headers': 'en-têtes surnuméraires',
'invalid-column-delimiter': 'délimiteur de colonne incorrect',
'missing-headers': 'en-têtes manquant',
'wrong-headers-order': 'en-têtes non ordonnés',
# Validata custom checks
'french-siret-value': 'n° siret invalide',
'compare-columns-value': 'comparaison de colonne invalide',
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment