Ruby on Rails:使用数组中的记录计算天数并插入另一个数组中

时间:2013-06-17 08:27:30

标签: ruby-on-rails ruby-on-rails-3.2

我有一个数组,其中包含从表中提取的一些记录。

示例记录:

rec = ReworkCycle id: 6634, issue_id: 2651, status_id: 3, project_id: 14, created_on: "2013-05-29 07:41:06", old_status_id: 2

每个n

的数组中都有issue_id个此类记录

此处issue_idproject_id是唯一的。

考虑我在数组中有以下状态的记录:format = status(id)

[assigned(2), testing(3), hold(13), assigned(2), testing(3), reopened(7), assigned(2), testing(3),reopened(7), assigned(2), hold(13), testing(3), approved(27)]

我想要的是以下列方式减去两种状态的日期:

array << (assigned date - 1st reopened date) - hold date which is between assigned and 1st reopened date - assigned date or status next to hold

首先分配 - 首先重新打开,然后减去保留时间

第二个结果将在两个重新开放的状态之间出现。

array << (2nd reopen date - 1st reopen date) - hold state if any between 1st and 2nd reopen state dates - status next to hold state date

array << (approved date - last reopened state) - hold state date if any in this two states - status date next to hold state

重新打开的状态可以是数组中的任何计数。

任何帮助将不胜感激。

0 个答案:

没有答案