You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rally获取TimeentryItem返回空数据问题求助

解决Rally批量获取TimeEntryItem返回null的问题

看起来你的问题核心是批量拉取大规模工时数据时返回null,但单用户请求正常——结合运行两年才出现这个问题的背景,大概率是数据量增长后触发了Rally WSAPI的限制,或者原有代码没处理好分页/大场景下的请求逻辑。下面给你几个针对性的解决方案:

1. 优先处理分页逻辑,避免单次请求数据过载

Rally的WSAPI默认有分页限制(单次返回结果数通常有上限,比如默认200条),当你要拉取70+用户、30个项目的工时数据时,单次请求的数据量肯定远超这个上限,直接用autoLoad: true会导致后续页数据没加载,甚至因为请求超时/数据过大返回null。

修改代码手动处理分页,把所有页面的数据汇总后再处理:

launch: function() {
    let allTimeEntries = [];
    const timeEntryStore = Ext.create('Rally.data.wsapi.Store', {
        model: 'timeentryitem',
        pageSize: 1000, // 设置Rally允许的最大单页数量(别超过官方限制)
        autoLoad: false, // 取消自动加载,手动控制分页
        listeners: {
            load: function(store, records, success) {
                if (success) {
                    allTimeEntries = allTimeEntries.concat(records);
                    // 检查是否还有下一页,有则继续加载
                    if (store.hasNextPage()) {
                        store.nextPage();
                    } else {
                        // 所有数据加载完成,调用你的处理逻辑
                        this._onItemsLoaded(allTimeEntries);
                    }
                } else {
                    console.error('工时数据加载失败:', store.getProxy().getLastError());
                }
            },
            scope: this
        }
    });
    timeEntryStore.load();
}

2. 分批次请求,降低单次请求压力

如果数据量实在太大,分页也解决不了,可以按项目/用户维度拆分请求,比如先遍历所有项目,再逐个拉取项目下的工时数据,或者按用户分组请求:

launch: function() {
    // 先获取所有项目列表
    const projectStore = Ext.create('Rally.data.wsapi.Store', {
        model: 'Project',
        fetch: ['ObjectID', 'Name'],
        autoLoad: true,
        listeners: {
            load: function(store, projects) {
                // 遍历每个项目,拉取对应工时
                projects.forEach((project) => {
                    Ext.create('Rally.data.wsapi.Store', {
                        model: 'timeentryitem',
                        filters: [{
                            property: 'Project',
                            value: project.get('ObjectID')
                        }],
                        autoLoad: true,
                        listeners: {
                            load: (teStore, records) => {
                                // 处理当前项目的工时数据(比如累加进全局数组)
                                this._processBatchTimeEntries(records);
                            },
                            scope: this
                        }
                    });
                }, this);
            },
            scope: this
        }
    });
}

3. 排查API限流与超时问题

Rally的API有速率限制,批量高频请求可能触发限流导致返回null;另外大请求也容易超时。可以做这两个调整:

  • 给Store的proxy设置更长的超时时间:
Ext.create('Rally.data.wsapi.Store', {
    model: 'timeentryitem',
    proxy: {
        type: 'rally',
        timeout: 30000 // 30秒超时,根据实际情况调整
    },
    // 其他配置
});
  • 如果是连续发起请求,添加延迟避免触发限流(比如用Ext.defer控制请求间隔)

4. 加日志调试定位问题

在load事件里添加详细日志,能帮你精准定位是请求超时、数据超限还是其他错误:

load: function(store, records, success) {
    console.log('当前请求URL:', store.getProxy().url);
    console.log('返回记录数:', records.length);
    console.log('请求是否成功:', success);
    if (!success) {
        console.error('错误详情:', store.getProxy().getLastError());
    }
    // 后续处理逻辑
}

5. 检查API版本兼容性

你的应用运行了两年,Rally的API可能有更新,旧版本API可能对大请求的支持有问题。可以在Store里指定最新的稳定API版本:

Ext.create('Rally.data.wsapi.Store', {
    model: 'timeentryitem',
    apiVersion: 'v2.0', // 替换为Rally当前的稳定版本
    // 其他配置
});

内容的提问来源于stack exchange,提问作者Denis Raskin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:48:36