We have a state in our defects called "Need More Information". I would like to create a graph over time of how many defects are in that state at any particular period of time.
I think I can get the info to do that with the Lookback API with the following query:
my $find = {
State => 'Need More Information',
'_PreviousValues.State' => {'$ne' => 'Need More Information'},
_TypeHierarchy => -51006, # defect
_ValidFrom => {
'$gte' => '2012-09-01TZ',
'$lt' => '2012-10-23TZ',
}
I thought that would give me back a list of all defect snapshots where the defect was transitioning into "Need More Information" state, but it does not (seems to list everything that was ever in "Need More Information" state.
Technically what I need is a query that lists snapshots of any defects transitioning either TO OR FROM the "Need More Information" state, but since this simpler one did not seem to work as I expected, I thought I would ask first why the query above did not work the way I expected.
The "Generated Query" in the header that comes back is:
'fields' => 1,
'skip' => 0,
'limit' => 100,
'find' => {
'_TypeHierarchy' => -51006,
'_ValidFrom' => {
'$gte' => '2012-09-01T00:00:00.000Z',
'$lt' => '2012-10-23T00:00:00.000Z'
},
'_PreviousValues.State' => {
'$in' => [
undef,
5792599066,
5792599067,
5792599065,
5792599070,
5792599071,
5792599068,
5792599073,
5792599072,
5792599075,
5792599077,
5792599076,
5792599078,
3631859989,
3631859988,
3631859987,
3631859986
]
},
'State' => {
'$in' => [
4384150044
]
}
}
};
I tried leveraging the $nin
clause and had success with it. You might try adjusting your query to resemble something like this:
find: {
_Type: 'Defect',
State: 'Need More Information',
'_PreviousValues.State': {
$in: [
'Submitted', 'Open', 'Fixed', 'Closed'
]
},
etc...
}