How to use startOfYear()/endOfYear() functions in Jira JQL? - jira

I am trying to churn a report using JQL filter that displayed monthly ticket assigned to particular person in a year.
I am really confused regarding the usage of StartofYear() and EndofYear()
Since we only started using JIRA in November, below query should return data for the month of November (11M) but I am not sure why, the query below is not returning any data...
after startofyear("+11M") before endofyear("+11M")
From what I understand, the above query should return data from Starting of November to end of November right?

The offset parameter in the startOfYear/endOfYear functions is the offset of whole years (e.g. startOfYear(-1) means start of the last year).
Also, you need to specify an object that you want to limit to these months (e.g. issues created or resolved). And you need to use different operators.
In your case, you need to use any of the following JQLs:
created >= startOfMonth(-1) AND created <= endOfMonth(-1) (for November when executed in December)
created >= 2021-01-11 AND created <= 2021-11-30
Instead of <= endOfMonth(-1) you can use < startOfMonth().
See also more information in Atlassian Documentation.

Related

TFS query for items completed yesterday to use weekdays

I have a query for "items completed yesterday" which is super useful in standups.
But #today - 1 seems to look at calendar days, not weekdays/workdays meaning that my query isn't useable on Mondays. Is there a way to tweak it to work?
Unfortunately we cannot achieve that.
You can Set working days for team's sprint planning and tracking when calculating capacity and sprint burndown, however it's not apply to work item queries.
So, as a workaround you can create another query with Closed Date = #today - 3 specified if you are using the normal working days...(Means the "Yesterday" is Friday)
More information please see Query by date or current iteration.

Show 3 items based on a date that can be future and past

I have a model that holds a date that can be either upcoming or past. I preferably want to see the 3 upcoming items. But if there aren't any, I want to show the ones that have already past, with the most recent first.
So if there are all future ones:
future - future - future
If there are only two future ones:
past - future - future
How should I achieve this in my model?
if is range that you want you can adapt this for your case.
month = Date.today
range = ["`users`.`created_at`>= '#{month.beginning_of_month}') AND (`users`.`created_at` <= '#{month.end_of_month}'"]
User.where(range)
you can use simple data manipulation with rails by rails .order method
ex: Model.all.order('created_at DESC').limit(3)
This will give you last 3 future records.

Indexing or Labeling is best in Neo4j

I Need to show the latest posts. In future, there will be around billions of posts.
So which is the optimized way to show the latest posts list.
By storing every post's month as 201506 and indexing it. or
By creating label as 201506 .. 201508 and storing the post in their particular label.
Then retrive the posts in descending order based on every month, Or is there any other way to do this.
Also if i have more labels, whether it will affect the performance or not.
If you want to have an ordered list of all posts in your system (regardless of the author) you might organize it as a linked list representing your timeline:
(post1:Post) -[:PREV_POST]-> (post2:Post) -[:PREV_POST]-> ...
So the PREV_POST relationship connects the most recent post to the previous one.
Additionally you might have a timetree (see http://graphaware.com/neo4j/2014/08/20/graphaware-neo4j-timetree.html as a sample implementation). Since your maximum domain granularity is month, you have years and months in the timetree.
Only the first post for every month is then connected to the month node in the time tree. See below for a sample model:
To query e.g. the posts in decending order for Dec 2014 we first find the respective month (Dec 2014) in the timetree, go to the next month (Jan 2015). From the two month nodes we go to the first post of that month and find everything in between:
MATCH (:TimeRoot)-[:HAS_YEAR]->(startMonth:Year{year:2014})-[:HAS_MONTH]->(endMonth:Month{month:Dec}),
(startMonth)<-[:FIRST_IN_MONTH]-(firstPost:Post),
(endMonth)<-[:FIRST_IN_MONTH]-()-[:PREV_POST]->(lastPost:Post),
path = (lastPost)-[:PREV_POST*]->(firstPost)
UNWIND nodes(path) as post
RETURN post
Please note that I've not actually tested the query, so there might be some typos. The intention was to demo the model, not the full solution.

Jira - JQL report to show average number of resolved/created tickets over 30days

I'm trying to figure out how to create a JQL query that will pull back the average number of resolved tickets over the last 30 days and the average number of created tickets over the last 30 days...
I've used the created resolved report in Jira which is great, but now I just need the averages calculated..
I'm quite sure that this cannot be achieved using the out-of-the-box JQL.
You can do this easily using Jira's remote API, using jira-python for example :
from jira.client import JIRA
jira = JIRA(basic_auth=('admin', 'admin')) # a username/password tuple
props = jira.application_properties()
# Find all issues from the last month:
issuesResolved = jira.search_issues('resolved > startOfMonth()')
issuesCreated = jira.search_issues('created > startOfMonth()')
# and so on...
What should the output be exactly? average per day for the last 30 days? average for every 30 months?
Anyway, if you need help coding that let me know... good luck !

Find WorkItems that were assigned to X in the last 30 days

I'm trying to find all WorkItems that were assigned to a person X in the last 30 days.
The big problem I have is the "in the last 30 days"-part.
I thought about using the "ever" or "asof" keywords, but couldn't find a good answer yet.. something like WHERE [Assigned To] = 'X' AND (([Assigned To] != 'X') asof '<30daysago>').
But this is still not a bulletproof solution.
Any better ideas?
Thanks & kind regards
Simon
It appears that this is not possible using just WIQL, but you can get close.
The keyword #Today will give you today's date, then just subtract your range from it. The EVER keyword applied to [Status]='AssignedTo' and a comparison against a date 30 days in the past to [StateChangeDate] is what you'll need to accomplish this.
As close as you can get with WIQL and existing fields:
This says, from all revisions (status changes) return records where the user 'X' has ever been AssignedTo and the State has changed in the last 30 days. This will basically give you a slightly fuzzy picture of what your User has been working on in the last month.
WHERE [Microsoft.VSTS.Common.StateChangeDate] >= #today - 30
AND [System.AssignedTo] EVER 'Bennett Aaron'
ORDER BY [System.State]
Add the missing field:
You could add a custom field called AssignedDate that is captured during the New->AssignedTo workflow transition that you create in the Work Item Definition XML. You can accomplish this using the Team Foundation Server Power Tools extension to Visual Studio. This would give you exactly what you need as well as additional reporting options going forward.
TFS API
I cannot help you with this one, but I believe you could query using the TFS API.
A couple of quick gotchas I've experienced to save you time on ASOF and EVER:
AsOf won't help you by itself with this as it does not support a range of dates. It allows you to query as if it were another date. In other words, if you forgot to capture the results of a query yesterday, you can use an AsOf query to get the results that you would have gotten had it run yesterday. What I understand is that you want to query a basic date range.
EVER might not work as you expect against dates as I believe it uses the exact value of the field (timestamp portion of the date field would be included) it tests with. Just make sure the EVER keyword is used against the status field rather than a date.

Resources