Commit d46f3308 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

wip - no errors report is ok

parent 310ee17c
......@@ -4,7 +4,7 @@
{% if with_lineno_col %}
<th scope="col">1</th>
{% endif %}
{% for h in report.table.headers %}
{% for h in report.table.header %}
<th
scope="col"
{% if report.table.cols_alert[loop.index - 1] != "" %}class="{{ report.table.cols_alert[loop.index - 1] }}"{% endif %}
......
......@@ -195,13 +195,13 @@ def extract_source_data(source: ValidataResource, schema_descriptor, preview_row
source_header_info = [(colname, False) for colname in source_header]
rows_count = len(source_rows)
previous_rows_count = min(preview_rows_nb, rows_count)
preview_rows_count = min(preview_rows_nb, rows_count)
return {
'source_header_info': source_header_info,
'header': source_header,
'rows_nb': rows_count,
'data_rows': source_rows,
'preview_rows_count': previous_rows_count,
'preview_rows_count': preview_rows_count,
'preview_rows': source_rows[:preview_rows_count]
}
......@@ -384,18 +384,16 @@ def create_validata_ui_report(validata_core_report, schema_dict):
report = copy.deepcopy(validata_core_report)
# One table is enough
del report['table-count']
report['table'] = report['tables'][0]
del report['tables']
del report['table']['error-count']
del report['table']['time']
del report['table']['valid']
del report['valid']
# use _ instead of - to ease information picking in jinja2 template
report['table']['row_count'] = report['table']['row-count']
report['table']['row_count'] = report['table']['stats']["rows"]
# Handy col_count info
headers = report['table'].get('headers', [])
headers = report['table']['header']
report['table']['col_count'] = len(headers)
# Computes column info
......@@ -416,7 +414,6 @@ def create_validata_ui_report(validata_core_report, schema_dict):
# Count errors
report['error_count'] = len(errors)
del report['error-count']
# Then group them in 2 groups : structure and body
report['table']['errors'] = {'structure': [], 'body': []}
......@@ -450,12 +447,15 @@ def create_validata_ui_report(validata_core_report, schema_dict):
report['repair_actions'] = compute_repair_actions(report['table']['errors']['structure'])
# Sort by error names in statistics
report["table"]["error-stats"] = {}
report["table"]["count-by-code"] = {}
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)
stats[key] = {}
stats[key]["count-by-code"] = {}
stats[key]['count-by-code'] = sorted(((translate_error_code(k), v)
for k, v in stats[key]['count-by-code'].items()), key=itemgetter(0))
return report
......@@ -540,13 +540,13 @@ def validate(schema_instance: SchemaInstance, source: ValidataResource):
flash_error('Erreur de source : {}'.format(msg))
return redirect(url_for('custom_validator'))
source_data = extract_source_data(source, schema_instance.schema.descriptor)
source_data = extract_source_data(source, schema_instance.schema)
# handle report date
report_datetime = datetime.fromisoformat(validata_core_report['date']).astimezone()
# Enhance validata_core_report
validata_report = create_validata_ui_report(validata_core_report, schema_instance.schema.descriptor)
validata_report = create_validata_ui_report(validata_core_report, schema_instance.schema)
# Display report to the user
validator_form_url = compute_validation_form_url(schema_instance.request_parameters())
......
Supports Markdown
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