2

I want to get Feature object for User Stories that I got from lookback API. But when I try to hydrate Feature I get only UnFormatted feature ID.

Can I get real Feature objects for User Stories from lookback result set?

Below the example of code that I use for retrieving data:

storeConfig: {
            find: {
                "_TypeHierarchy": { '$in' : [-51038] },
                "Children": null
            },
            fetch: ["ScheduleState", "PlanEstimate", "ObjectID", "_ValidFrom", "_ValidTo", "c_BaselineDeliveryConfidence", "Name", "Feature"],
            hydrate: ["ScheduleState", "c_BaselineDeliveryConfidence", "Name", "Feature"],
            sort: {
                "_ValidFrom": 1
            },
            compress: true,
            useHttpPost: true
anw_k
  • 31
  • 2

2 Answers2

2

It is not possible to hydrate objects straight out of the LBAPI. However, I have been working on a helper class to do just that, using a method similar to what Nick suggested.

https://github.com/ConnerReeves/RallyHelpers/blob/master/RecordHydrator/RecordHydrator.js

Here's an example of how it's used. I'm gathering all leaf User Stories (that have an iteration assignment) and then hydrating that Initiative field:

launch: function() {
    var self = this;
    Ext.create('Rally.data.lookback.SnapshotStore', {
        limit   : Infinity,
        fetch   : ['Name','Iteration'],
        filters : [{
            property : '__At',
            value    : 'current'
        },{
            property : '_TypeHierarchy',
            value    : 'HierarchicalRequirement'
        },{
            property : 'Iteration',
            operator : '!=',
            value    : null
        },{
            property : 'Children',
            value    : null
        }]
    }).load({
        params : {
            compress                    : true,
            removeUnauthorizedSnapshots : true
        },
        callback : function(records, operation, success) {
            self._hydrateRecords(records);
        }
    });
},

_hydrateRecords: function(records) {
    Ext.create('CustomApp.RecordHydrator', {
        fields: [{
            name    : 'Iteration',
            hydrate : ['Name','StartDate','EndDate']
        }]
    }).hydrate(records).then({
        success: function(hydratedRecords) {
            console.log(_.groupBy(hydratedRecords, function(record) {
                return record.get('Iteration') && record.get('Iteration').get('Name');
            }));
        }
    });
}
Conner Reeves
  • 1,381
  • 8
  • 13
0

Feature is a full object to which a user story has a reference to (via Feature attribute). Your code which is similar to this query:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/111/artifact/snapshot/query.js?find={"_TypeHierarchy":"HierarchicalRequirement"}&fields=["Name","ScheduleState","PlanEstimate","Feature"]&hydrate=["ScheduleState"]

will return something like this:

{
Feature: 12483739639,
Name: "my story",
ScheduleState: "Defined",
PlanEstimate: 3
}

where 12483739639 is ObjectID of the Feature. Adding "Feature" to the hydrate will not make a difference.

If you want to get the full Feature object or some of its attributes, in your code you may use the OID of the feature and issue a separate query. You may also push those OIDs into an array and use $in operator in that second query.

nickm
  • 5,936
  • 1
  • 13
  • 14