Custom Calculations

Targetprocess REST API v.2 is quite powerful with its ability to do advanced calculations. In a single API v.2 request you can perform common math operations over entities in root result collection and in nested ones. As a result you get calculated numeric, date, boolean, text values.

📘

Besides Calculations performed within REST API there are a few other features in Targetprocess that support custom calculations. More information: Custom Calculations and Formula Expressions

Selectors: Custom Calculations over nested collections

You can request inner collections with filters, projections, and aggregations. E.g. I want to get projects with:

  • all non-closed bugs
  • sum of feature efforts
  • count of opened requests

  • openBugs:Bugs.Where(EntityState.IsFinal!=true) - all non-closed bugs. We need to specify name of the result collection. As far as Bugs is a collection of bug we can use some standard Enumerable methods (see below)
  • featureEffort:features.sum(effort) - we can aggregate collections by some field of collection item.
  • openRequestCount:requests.Count(EntityState.IsInitial==true) - we can calculate counts with some filters.

Final selectors: Custom Calculations over result output

It's possible to use aggregation on root collection.

Example: I want to get count of all user stories: userstories?result=Count

Result is:

81

Example: I want to get sum, average, min and max efforts from all user stories:

/api/v2/userstory?result={sum:sum(effort),average:average(effort),min:min(effort),max:max(effort)}

Result is:

{
  "sum": 1168.0000,
  "average": 14.419753,
  "min": 6.0000,
  "max": 29.0000
}

Example: I want to get effort sum from all user stories, that have tasks and ids > 50:

/api/v2/userstory?where=id%3E50%20AND%20Tasks.count!=0&result={sum:sum(effort)}

Result is:

{
  "sum": 259.0000
}

.NET Expressions

API v2 uses LINQ expression parser that use syntax that is very close to standard .NET syntax. More information: .NET Expressions