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

IVS-205 - Limit number of outcomes per rule #120

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

rw-bsi
Copy link
Contributor

@rw-bsi rw-bsi commented Nov 11, 2024

Limit # of outcomes to 10 (configurable) + moved some of grouping/title logic to backend

Example:
image

Copy link
Collaborator

@aothms aothms left a 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'
Copy link
Collaborator

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:

Suggested change
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 = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
schema_results_count[title] = schema_results_count[title] + 1 if title in schema_results_count else 1
schema_results_count[title] += 1

Comment on lines 469 to 471
'normative': {},
'prerequisites': {},
'industry': {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Contributor Author

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

@rw-bsi rw-bsi self-assigned this Nov 12, 2024
@rw-bsi rw-bsi requested a review from aothms November 12, 2024 00:54
@civilx64 civilx64 merged commit 215beb8 into development Nov 12, 2024
3 checks passed
@civilx64 civilx64 deleted the IVS_205_Limit_Number_of_Outcomes branch November 12, 2024 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants