-
Notifications
You must be signed in to change notification settings - Fork 8
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
IVS-205 - Limit number of outcomes per rule #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done! Courageous to touch this messy logic and move it around. Only some cosmetic things from my side.
@@ -435,6 +438,15 @@ def report(request, id: str): | |||
"msg": outcome.observed, | |||
"task_id": outcome.validation_task_public_id | |||
} | |||
|
|||
key = mapped['attribute'] if 'attribute' in mapped and mapped['attribute'] else 'Uncategorized' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had read this several times, can this be abbreviated to:
key = mapped['attribute'] if 'attribute' in mapped and mapped['attribute'] else 'Uncategorized' | |
key = mapped.get('attribute', None) or 'Uncategorized' |
@@ -418,14 +419,16 @@ def report(request, id: str): | |||
logger.info('Fetching and mapping syntax done.') | |||
|
|||
# retrieve and map schema outcome(s) + instances | |||
schema_results_count = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schema_results_count = {} | |
schema_results_count = defaultdict(int) |
_type = mapped['constraint_type'] if 'constraint_type' in mapped and mapped['constraint_type'] else 'Uncategorized' | ||
title = _type.replace('_', ' ').capitalize() + ' - ' + key | ||
mapped['title'] = title # eg. 'Schema - SegmentStart' | ||
schema_results_count[title] = schema_results_count[title] + 1 if title in schema_results_count else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schema_results_count[title] = schema_results_count[title] + 1 if title in schema_results_count else 1 | |
schema_results_count[title] += 1 |
'normative': {}, | ||
'prerequisites': {}, | ||
'industry': {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'normative': {}, | |
'prerequisites': {}, | |
'industry': {} | |
'normative': defaultdict(int), | |
'prerequisites': defaultdict(int), | |
'industry': defaultdict(int), |
# TODO: organize this differently? | ||
key = 'Schema - Version' if label == 'prerequisites' else mapped['feature'] | ||
mapped['title'] = key | ||
grouped_gherkin_outcomes_counts[label][key] = grouped_gherkin_outcomes_counts[label][key] + 1 if key in grouped_gherkin_outcomes_counts[label] else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grouped_gherkin_outcomes_counts[label][key] = grouped_gherkin_outcomes_counts[label][key] + 1 if key in grouped_gherkin_outcomes_counts[label] else 1 | |
grouped_gherkin_outcomes_counts[label][key] = += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo but replaced with += 1
Limit # of outcomes to 10 (configurable) + moved some of grouping/title logic to backend
Example: