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

Allow user to decide what happens on a tie #6

Open
2 tasks
peterwoodworth opened this issue Nov 18, 2021 · 0 comments
Open
2 tasks

Allow user to decide what happens on a tie #6

peterwoodworth opened this issue Nov 18, 2021 · 0 comments

Comments

@peterwoodworth
Copy link
Member

Description

There should be a non-required parameter (which defaults to how it currently works) which allows the user to decide what happens on a tie.

Currently on a tie, the action first reruns the area determining function, but sets the similarity to 0. Meaning, we are eliminating words detected in the first run that were not exact keyword matches. This may cause the tie to break, but it might still tie on the second run.
If it ties with a similarity of 0, the action only acts on one area: the area it chooses is the first area that was mentioned in the issue.

You should also be able to set it so that the action works on all issues that achieved the highest score. Additionally, the user might not want the action to rerun the area determining function with a similarity of 0 to attempt to break a tie.

Use Case

More configurability for the user

Proposed Solution

The code is currently here in Issue.determineArea()

let winningArea = '';
let winners: Map<string,number> = new Map();
for (let area of potentialAreas.entries()) {
if(winners.size === 0) {
winners.set(area[0], area[1]);
} else if (area[1] > winners.values().next().value) {
winners = new Map();
winners.set(area[0], area[1]);
} else if (area[1] === winners.values().next().value) {
winners.set(area[0], area[1]);
}
}
// tiebreaker goes to the area with more *exact* keyword matches
if(winners.size > 1 && this.similarity !== 0) {
this.similarity = 0;
winningArea = this.determineArea();
} else if (winners.size > 0) {
winningArea = winners.keys().next().value;
}
winningArea = winners.keys().next().value;
console.log("Winning area: " + winningArea);
return winningArea;

It might be best to create a separate member function of Issue for the tiebreaker code and have Issue.determineArea() call that function

It will need to be modified to support different options depending on a new parameter which should be added to action.yml, something like this:

tiebreaker:
  description: "blahblahblah"
  required: false
  default: false

Other Info

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant