Lookback API queries for scheduled and unscheduled stories

Document ID : KB000057575
Last Modified Date : 14/02/2018
Show Technical Document Details

Issue

How to use Lookback API to find all restored stories in an iteration.

Resolution

To make the queries work in your subscription replace ObjectIDs used below with ObjectIDs of workspace, project and iteration valid in your subscription.

We start with this query. It returns snapshots of stories that meet this condition "_PreviousValues.Iteration":{"$exists":true}

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"Project":14281381969,"_TypeHierarchy":"HierarchicalRequirement","_PreviousValues.Iteration":{"$exists":true}}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

The results will include snapshots where previous value of iteration was null:

_PreviousValues: {Iteration: null },

even in cases when a new story is created directly on the Iteration details page using Action > Schedule New User Story.

To filter out those snapshots, and include only snapshots where iteration was changed the "not null" condition may be added:

"_PreviousValues.Parent":{"$ne":null}

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"Project":14281381969,"_TypeHierarchy":"HierarchicalRequirement","_PreviousValues.Iteration":{"$exists":true},"_PreviousValues.Iteration":{"$ne":null}}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

Here is an example of a returned result:

Results: [
{
_ValidFrom: "2014-09-19T20:39:56.718Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: 23000081850,
Iteration: 23000081331,
_PreviousValues: {
Iteration: 23000075166
},
FormattedID: "US59"
}
]


Notice different iteration ObjectIDs: current value 23000081331 and previous value 23000075166

If a story was schedule for an iteration, unscheduled, and then scheduled back for the same iteration the same query will return one snapshot, and will not include a snapshot where previous value was null.

{
ObjectID: 22999892100,
_PreviousValues: {
Iteration: 23000075166
},
_ValidFrom: "2014-09-19T20:45:24.989Z",
_ValidTo: "2014-09-19T20:46:38.344Z",
FormattedID: "US58"
}


The snapshot above represents a revision "3 Iteration removed [i1Q2]. Notice that at the time of this snapshot this story no longer had iteration value, hence there is only previous iteration included in the json:
_PreviousValues: {
Iteration: 23000075166
}


User-added image

If we are only interested in snapshots with a specific current iteration, regardless if the value of previous iteration (null or any other iteration) the following variation of the same query

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"Project":14281381969,"_TypeHierarchy":"HierarchicalRequirement","Iteration":23000081331}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

will return both a snapshot with _PreviousValues: {Iteration: 23000075166} and _PreviousValues: {Iteration: null}

Results: [
{
_ValidFrom: "2014-09-19T20:39:56.718Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: 23000081850,
Iteration: 23000081331,
_PreviousValues: {
Iteration: 23000075166
},
FormattedID: "US59"
},
{
_ValidFrom: "2014-09-19T21:04:19.615Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: 23001125746,
_PreviousValues: {
Iteration: null
},
Iteration: 23000081331,
FormattedID: "US61"
}
]


If we are only interested in snapshots with a specific current iteration where the previous iteration was null this variation of the same query

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"Project":14281381969,"_TypeHierarchy":"HierarchicalRequirement","Iteration":23000081331,"_PreviousValues.Iteration":null}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

will return the result, which consists of only one snapshot related to US61:

Results: [
{
_ValidFrom: "2014-09-19T21:04:19.615Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: 23001125746,
_PreviousValues: {
Iteration: null
},
Iteration: 23000081331,
FormattedID: "US61"
}
]


Finally, let's consider a scenario when an iteration "A" is deleted and stories are unscheduled from it automatically. A deleted iteration does not go to a recycle bin, but is deleted permanently.
We can use this query syntax to find stories where _PreviousValues.Iteration is not null:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1011574887/artifact/snapshot/query.js?find={"Project":1791266714,"_TypeHierarchy":"HierarchicalRequirement","_PreviousValues.Iteration":{"$exists":true},"_PreviousValues.Iteration":{"$ne":null}}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

This endpoint will return snapshots of stories that at one point or another were scheduled for iteration "A", "B", "C". This query is not specific to iteration "A" since at this point we do not have iteration "A"'s ObjectID.

However if among the snapshots returned by this query we can identify at least one user story that we know used to be scheduled for iteration "A", the snapshot will include the ObjectID of the deleted iteration "A".

{
  • _ValidFrom: "2015-09-10T20:55:01.410Z",
  • _ValidTo: "9999-01-01T00:00:00.000Z",
  • ObjectID: 12344309601,
  • _PreviousValues:
    ?
    {
    • Iteration: 12137561035
    },
  • FormattedID: "US2720"
}
Now we can hit the same endpoint in a more targeted way:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1011574887/artifact/snapshot/query.js?find={"_TypeHierarchy":"HierarchicalRequirement","_PreviousValues.Iteration":12137561035}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true
?