Lookback API queries for scheduled and unscheduled stories
search cancel

Lookback API queries for scheduled and unscheduled stories

book

Article ID: 57575

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

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

Environment

Release:
Component: ACSAAS

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/<WORKSPACE_OID>/artifact/snapshot/query.js?find={"Project":<PROJECT_OID>,"_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/<WORKSPACE_OID>/artifact/snapshot/query.js?find={"Project":<PROJECT_OID>,"_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: <OBJECT_OID>,
Iteration: <CURRENT_ITERATION_OID>,
_PreviousValues: {
Iteration: <PREVIOUS_ITERATION_OID>
},
FormattedID: "US59"
}
]


Notice different iteration ObjectIDs: current value <CURRENT_ITERATION_OID> and previous value <PREVIOUS_ITERATION_OID>

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: <OBJECT_OID>,
_PreviousValues: {
Iteration: <ITERATION_OID>
},
_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: <ITERATION_OID>
}


 

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/<WORKSPACE_OID>/artifact/snapshot/query.js?find={"Project":<PROJECT_OID>,"_TypeHierarchy":"HierarchicalRequirement","Iteration":<ITERATION_OID>}&fields=["ObjectID","_ValidFrom","_ValidTo","FormattedID","Iteration","_PreviousValues.Iteration"]&compress=true

will return both a snapshot with _PreviousValues: {Iteration: <ITERATION_OID>} and _PreviousValues: {Iteration: null}

Results: [
{
_ValidFrom: "2014-09-19T20:39:56.718Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: <OBJECT_OID>,
Iteration: <CURRENT_ITERATION_OID>,
_PreviousValues: {
Iteration: <PREVIOUS_ITERATION_OID>
},
FormattedID: "US59"
},
{
_ValidFrom: "2014-09-19T21:04:19.615Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
ObjectID: <OBJECT_OID>,
_PreviousValues: {
Iteration: null
},
Iteration: <ITERATION_OID>,
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/<WORKSPACE_OID>/artifact/snapshot/query.js?find={"Project":<PROJECT_OID>,"_TypeHierarchy":"HierarchicalRequirement","Iteration":<ITERATION_OID>,"_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: <OBJECT_OID>,
_PreviousValues: {
Iteration: null
},
Iteration: <ITERATION_OID>,
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/<WORKSPACE_OID>/artifact/snapshot/query.js?find={"Project":<PROJECT_OID>,"_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: <OBJECT_OID>,
  • _PreviousValues:
    ?
    {
    • Iteration: <ITERATION_OID>
    },
  • FormattedID: "US2720"

}
Now we can hit the same endpoint in a more targeted way:

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