bug状态随时间变化

时间:2014-06-10 13:29:47

标签: mysql time

我已经在mysql查询上工作了一段时间,它会在特定时间给我bug状态(bug_id,bug_severity,分辨率,排名等等)我正在使用bugzilla 3.42数据库,而我拥有我需要的所有列,在不同的表中,我创建的查询将告诉我在某个特定时间内状态发生了什么变化(例如,列bug_when是03-03-2014,只有bug_severity列被填充,其他是空值)。这是我的代码:

  select
ba.bug_id,  ba.bug_when,
case when fd.name='bug_id' then removed end as bug_id,
case when fd.name = 'product' then removed end as product,
case when fd.name = 'version' then removed end as version,
case when fd.name = 'bug_status' then removed end as status,
case when fd.name = 'resolution' then removed end as resolution,
case when fd.name = 'bug_severity' then removed end as severity,
case when fd.name = 'component' then removed end as component,
case when fd.name = 'rank' then removed end as rank,
case when fd.name = 'rank_number' then removed end as rank_number,
case when fd.name = 'occurence' then removed end as occurence,
case when fd.name = 'responsible_team' then removed end as responsible_team
from bugs_activity as ba
inner join fielddefs as fd on ba.fieldid=fd.id  
where fd.name in ('bug_id', 'product', 'version', 'bug_status', 'resolution',       'bug_severity', 'component', 'rank', 'rank_number', 'occurence', 'cf_responsible_team')
order by ba.bug_id

但是,我需要有一些查询,它会在一段时间内给我以前所有的状态。例如,在04-04-2014,我所有的领域都需要在那个时期填满他的州。我在bugs表中有他的最后一个状态,以及表bugs_activity,我有时间在bug改变他的一些状态时,我已经添加并删除了状态。 这是bugzilla架构,我有从那里的所有表 http://www.ravenbrook.com/tool/bugzilla-schema/?action=single&version=3.4&view=View+schema

任何帮助?

1 个答案:

答案 0 :(得分:0)

如果您需要在特定时间捕获错误状态的快照,可以添加WHERE子句以选择bugs_activity行的子集。

尝试将其添加到示例查询中的where子句中。

   AND ba.bug_when < '2014-04-04` + INTERVAL 1 DAY

这将忽略您指定日期后一天午夜后的所有bugs_activity行。这应该表明你提到的那一天的每个错误的状态。

您可能还需要以类似的方式过滤架构中的其他表。

相关问题