Rally App SDK 2.0 - 按日期过滤

时间:2014-03-13 17:54:29

标签: rally appsdk2

是否可以构建一个wsapi.Filter来过滤掉基于StartDate和EndDate的迭代?我想做像

这样的事情
{
  property: 'StartDate',
  operator: '>=',
  value: myStartDate
}

{
  property: 'EndDate',
  operator: '<=',
  value: myEndDate
}

但它似乎没有用。我甚至无法弄清楚如何手动查询Web Services API页面上的迭代;我不确定如何正确格式化日期字符串。

1 个答案:

答案 0 :(得分:1)

您可以尝试在过去90天内按StarDate过滤的此代码。请参阅控制台中的输出:

Ext.define('CustomApp', { extend: 'Rally.app.App', componentCls: 'app',

        launch: function() {

        this.loadIterations(); 
        },

loadIterations: function() {
        var millisecondsInDay = 86400000;            
        var currentDate = new Date();
        var startDate = new Date(currentDate - millisecondsInDay*90);
        var startDateUTC = startDate.toISOString();
        console.log('startDateUTC',startDateUTC);
        console.log('startDate',startDate);
        var iterations = Ext.create('Rally.data.WsapiDataStore', {
            model: 'Iteration',
            autoLoad: true,
            fetch: ['ObjectID', 'Name', 'StartDate', 'PlannedVelocity'],
            filters:[
                {
                        property: 'StartDate',
                        operator: '>=',
                        value: startDateUTC
                }
            ],
            sorters: [
                {property: 'StartDate', direction: 'ASC'}
            ],
            listeners: {
                load: function(store, data, success) {
                    Ext.Array.each(data, function(record) {
                        console.info('ID: ', record.get('ObjectID'), 
                            '  Name: ', record.get('Name'),                             
                            '  StartDate: ', record.get('StartDate'), 
                            '  PlannedVelocity: ', record.get('PlannedVelocity'));
                    });
                }, scope: this
            }
        });        
}    
});