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

Best Practice for Rules Configurations #100

Open
jprettyman opened this issue Jan 15, 2020 · 3 comments
Open

Best Practice for Rules Configurations #100

jprettyman opened this issue Jan 15, 2020 · 3 comments
Labels
documentation Should be reflected in Documentation or FAQ update pinned Stops stale[bot] from closing this issue question Further information is requested

Comments

@jprettyman
Copy link

jprettyman commented Jan 15, 2020

This is more of a question for clarification as opposed to a feature request.

I am looking on guidance on best practices on setting up and implementing rules. Because my rules need to traverse the hierarchy both up and down, I would like to ensure that I implement these rules in the most efficient manner.
The question is: Should I implement a rule per work item or have a single rule with both worktime methods in them?
My Current Task rule looks like this:

if (self.Parent != null && self.WorkItemType == "Task")
{
    var parent = self.Parent;
    var children = parent.Children;
        foreach (var child in children )
	{
		// Only get values from tasks
		if (child.WorkItemType == "Task")
		{
			totValue +=  Convert.ToDouble(child["Microsoft.VSTS.Scheduling.CompletedWork"]);
			remainValue +=  Convert.ToDouble(child["Microsoft.VSTS.Scheduling.RemainingWork"]);
		}
	}
	// only write if there is a summed value
	if (totValue > 0)
	{
		parent["Microsoft.VSTS.Scheduling.CompletedWork"] = totValue;
	}
	// only write if there is a summed value
	if (remainValue > 0)
	{
		parent["Microsoft.VSTS.Scheduling.RemainingWork"] = remainValue;
	}
}

I need to add another set of functionality for PBIs and Bugs such that some fields will be written to the tasks when the PBI or Bug is modified. I am looking to ensure that I do not get into a cyclical loop where the Task updates the Bug and then the bug updates the task. How to ensure calls do not get out of hand.
So, Is it best to have the entire operation in a single rule or create a rule for each work item?
image

@jprettyman jprettyman added the enhancement New feature or request label Jan 15, 2020
@BobSilent BobSilent added question Further information is requested and removed enhancement New feature or request labels Jan 15, 2020
@BobSilent
Copy link
Collaborator

BobSilent commented Jan 17, 2020

So let me start with some information and maybe at the end this is something which should be reflected in our documentation.

My Rules of Thumb

  1. Execution Flow: First of all define criteria's, when the rule should not be executed (exit condition)
  2. One Field should be updated only by one rule
  3. A rule can update multiple fields
  4. Try to update only self and work items in direct relation to self, or in other words do not update work items not in relation with self. As saving the changed items will lead to a new work item update event which will be handled. This way an information can ripple up or down and that's why the exit condition is so important

When writing the Rule

  1. First step in rule execution is checking the exit conditions and exit if required
  2. Start with checking simple exit conditions before getting more complex (means first check all on self before checking any related work item, as this also means a server roundtrip to get the data)

Look here for some more advanced examples.

...to be continued

@BobSilent BobSilent added the documentation Should be reflected in Documentation or FAQ update label Jan 17, 2020
@stale
Copy link

stale bot commented Mar 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 18, 2020
@stale stale bot closed this as completed Mar 25, 2020
@BobSilent BobSilent added pinned Stops stale[bot] from closing this issue and removed wontfix This will not be worked on labels Apr 4, 2020
@BobSilent
Copy link
Collaborator

i just reopen it, to update documentation with this information

@BobSilent BobSilent reopened this Apr 4, 2020
@giuliov giuliov pinned this issue Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Should be reflected in Documentation or FAQ update pinned Stops stale[bot] from closing this issue question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants