1

Hi I would like getting accepted story points from a multiprogramepic item on a specific date. In this case I would like to go back to the previous year. Why is it that I dont get any snapshot data which has accepted SP from the previous year?

This is currently my code which doesn't give me back the accepted SP from previous year:

_loadMP: function() {
     var mpEpics = Ext.create('Rally.data.wsapi.artifact.Store', {
            models: ['PortfolioItem/multiprogramepic'],
            fetch: ['FormattedID', 'Name', 'Owner', 'LeafStoryPlanEstimateTotal', 'AcceptedLeafStoryPlanEstimateTotal', 'PercentDoneByStoryPlanEstimate', 'PlannedStartDate', 'PlannedEndDate',  'Children'],
            autoLoad: true,
            limit: Infinity,
            pageSize: 9999,         
        });

        mpEpics.load().then({
            success: this._MPLoaded,
            scope: this
        });
    },

_MPLoaded: function(items) {
    var me = this;
    _.each(items, function(item) {
    me._calculatePreviousYear(item.get("ObjectID"), item.get("PlannedStartDate"), item.get("PlannedEndDate"));
},

_calculatePreviousYear: function(objID, startDate, endDate){
    var currentYear = Rally.util.DateTime.format(startDate, 'Y');
    var prevYear = new Date();
    prevYear.setFullYear(currentYear, 0, 1);
    prevYear.setHours(0, 0, 1); 
       var projectStore = Ext.create('Rally.data.lookback.SnapshotStore', {
            find: {
                _TypeHierarchy: {
                    '$in': ['HierarchicalRequirement']
                },
                _ItemHierarchy: objID,
                _ValidFrom: {
                    "$gte": startDate,
                    "$lte": prevYear
                },
            },
            fetch: ['FormattedID'],
            hydrate: ['Project'],
            sort: {
                "_ValidFrom": 1
            },
            limit: Infinity,
            context: this.getContext().getDataContext(),
            removeUnauthorizedSnapshots: true
        });

        console.log(objID, projectStore);
    }

1 Answers1

0

The lookback api's _ValidFrom and _ValidTo fields are strings, so it may just be that you need wrap the startDate and prevYear values with Rally.util.DateTime.toIsoString(). Not sure if the code is just representative or the actual working code but it looks like you're missing a } in _MPLoaded which could be impacting progress.

Joel Sherriff
  • 478
  • 2
  • 6