Jira aggregate worklogs only in specific dates range - jira

JIRA has an excellent ability to search issues with workLog items created in specific date and by a specific user. For example:
worklogDate > 2017-04-01 AND worklogDate < 2017-05-01 AND worklogAuthor = some-user
In this search result I can see a column Time Spent - it's a total time spent on a task. How can I aggregate time from workLogs only for selected days? For example, we worked on the task in Mar and April. How to write JQL to calculate only April's time.
It is possible?

To get the time spent by the user by tasks, if you have access to the database, you can run this query:
select wl.timeworked, wl.worklogbody, wl.updateauthor, wl.updated,
u.display_name, ji.summary,
concat(concat(p.pkey,'-'),ji.issuenum) as IssueKey
from worklog wl
inner join cwd_user u
on wl.updateauthor = u.user_name
inner join jiraissue ji
on ji.id = wl.issueid
inner join project p
on (ji.project = p.id)
where issueid in (
select j.ID
from jiraissue j
inner join project p
on (j.project = p.id)
where u.user_name = 'userid')
Replace the userid with the userid of the person that submitted the worklog. Take note that for each JIRA ticket (issue), there can be multiple worklog submission by different user. This will give you every worklog submitted by the userid and it will also show you which ticket (issue) they are for. You can add in the date constraint in the where clause if you want to just query for specific timeframe. The unit of measurement for the timeworked column is in second as recorded by JIRA.

According to Time Since Issues Report if JIRA's Documentation, Time Spend is the amount of time spent on the issue. This is the aggregate amount of time that has been logged against this issue. Are you looking to aggregate the time of one person in different issues?

Related

JIRA Query to track any and all activity between certain hours

A contractor I'm working with wants to give us a small bonus based on any "overtime" work we may or may not have done. Problem is, we didn't exactly keep a log of any activity we did outside of normal working day hours. I'm trying to use my Jira activity as a starting point. How can I track any and all activity (leaving a comment, changing a status, assigning the ticket to someone else, etc) conducted by me within certain hours, within certain dates.
For example, any and all activity conducted by me between the hours of 7PM - 8AM from February 3, 2021 to January 15, 2022.
You can get it from the Jira database.
For any activity, you can use following SQL query for retrieve any change in a project:
SELECT p.pname, p.pkey, i.issuenum, cg.ID, cg.issueid, au.lower_user_name, cg.AUTHOR, cg.CREATED, ci.FIELDTYPE, ci.FIELD, ci.OLDVALUE, ci.OLDSTRING, ci.NEWVALUE, ci.NEWSTRING
FROM changegroup cg
inner join jiraissue i on cg.issueid = i.id
inner join project p on i.project = p.id
inner join changeitem ci on ci.groupid = cg.id
inner join app_user au on cg.author = au.user_key
WHERE p.pkey = '<PROJECT_KEY>'
order by 1,3,4;
You can modify that query by filtering cg.CREATED in order to get activity between certain dates.
NOTE: Query can be changed depend on your database.
NOTE2: You can look that Atlassian link for further information.

SQL query report builder 3.0 table join problems with duplicates

I am having problems joining three tables in report builder 3.0. I have experimented with various joins and can not achieve the desired result.
PLACES
place ref,
address,
place type (place type = 1)
JOBS
place ref,
description,
cost,
job number,
JOBS INFO
job number,
date comp (date comp = 25/12/2015)
I need all places with place type 1.
Then I need to link all jobs completed 25/12/2015 by job number and then link these to places on place ref.
The first problem I have is despite which join I chose to link places to jobs and jobs info all I get is the places which have had jobs. I need to also show the places that haven't.
Also the database sometimes contains duplicate jobs so I only need to display the same job number once.
Any help with this would be much appreciated!
You need a LEFT JOIN when PLACES is your master table :
SELECT * FROM PLACES p
LEFT OUTER JOIN (select distinct * from Jobs j
INNER JOIN Jobs_Info ji ON(j.job_number = ji.job_number)
WHERE ji.date_comp = '25/12/2015') t
ON(p.place_ref = t.place_ref)
WHERE p.place_type = 1

bigQuery - Join

I'm trying to join two databases on the ID. The first database on price quotes does not have the data on websites, so I want to join it in from the logs database. However, in the logs database the ID is not unique, but the first chronological appearance of the ID - this is the right website.
When I run the query below, I get:
Resources exceeded during query execution.
Hence I don't know whether the problem is the code or something else.
Thanks
SELECT ID, user,busWeek, count(*) as num FROM [datastore.quotes]
Join (
select objectID, first(website) from (
select objectID, website, date from [datastore.allLogs]
order by date) group by objectID)
as Logs
on ID = objectID
group by ID,user,busWeek
Can you try:
SELECT ID, user,busWeek, count(*) as num FROM [datastore.quotes]
Join EACH (
select objectID, first(website) from (
select objectID, website, date from [datastore.allLogs]
order by date) group EACH by objectID)
as Logs
on ID = objectID
group by ID,user,busWeek
Note the 'EACH' - that keyword won't be needed in the future, but it's still useful today.
I think the issue is in ORDER BY. This brings all calculation to one node which causes "Resources Exceeded" message. I understand you need it to bring first (by date) website for each object.
Try to rewrite this select (inside join) to be partitioned.
For example using window functions with OVER(PARTITION BY ... ORDER BY)
In this case, I think, you have chance to make this in parallel
See below for reference
Window Functions

Neo4j cypher time interval histogram query of time tree

I would like to build an histogram on time series stored as time tree in neo4j.
The data structures are event done by a user each has timestamp, say user purchases category.
What I need to have is the number of browsing on each category by each user between start and end time, with interval of (1 second to days)
My model feats graph db very nicely, as I read neo4j documentation I could not find any way to do it in one query, and I'm afraid that calling for each user would be very slow.
I am aware to cypher capabilities, but I have no idea how to create such query.
I am looking for something like this (not working)
MATCH startPath=(root)-[:`2010`]->()-[:`12`]->()-[:`31`]->(startLeaf),
endPath=(root)-[:`2011`]->()-[:`01`]->()-[:`03`]->(endLeaf),
valuePath=(startLeaf)-[:NEXT*0..]->(middle)-[:NEXT*0..]->(endLeaf),
vals=(middle)-[:VALUE]->(event)
WHERE root.name = 'Root'
RETURN event.name, count(*)
ORDER BY event.name ASC
GROUP BY event.timestamp % 1000*60*10 // 10 minutes histogram bar
Then I'd like to have a report, for how many users browse to each site category:
0-9 news 5, commerce 3 ; 10-19 news 6, commerce 19; 1 20-29 news 2, commerce 8;
Any idea if it is optional with neo4j time tree model?
if so how? :-)
Does this work?
MATCH
startPath=(root)-[:`2010`]->()-[:`12`]->()-[:`31`]->(startLeaf),
endPath=(root)-[:`2011`]->()-[:`01`]->()-[:`03`]->(endLeaf),
valuePath=(startLeaf)-[:NEXT*0..]->(middle)-[:NEXT*0..]->(endLeaf),
vals=(middle)-[:VALUE]->(event)
WHERE root.name = 'Root'
RETURN event.name, event.timestamp % 1000*60*10 AS slice, count(*)
ORDER BY slice ASC
Basically I just added the event.timestamp % 1000*60*10 into the return so that Neo4j will use that as a grouping criteria

Report using Rails ActiveRecord group by

I am trying to generate a report to screen of accounting transaction history. In most situations it is one display row per record in the AccountingTransaction table. But occasionally there are transactions that I wish to display to the end user as one transaction which are really, behind the scenes, two accounting transactions. This is caused by deferral of revenues and fund splitting since this app is a fund accounting app.
If I display all rows one by one, those double entries look odd to the user since the fund splitting and deferral is "behind the scenes". So I want to roll up all the related transactions into one display row on screen.
I have my query now using group by to group the related transactions
#history = AccountingTransaction.where("customer_id in (?) AND no_download <> 1", customers_in_account).group(:transaction_type_id, :reference_id).order(:created_at)
as I loop through I get the transactions grouped as I want but I am struggling with how to display the total sum of the 'credit' field for all records in the group. (It is only showing the credit for the first record of the group) If I add a .sum(:credit) to my query, of course, it returns the sums just as I want but not all the other data.
Is there a way for me to group these records like in my #history query and also get the sum of the credit field for each respective group?
* Addition *
What I really want is what the following SQL query would give me.
SELECT transaction_type_id, reference_id, sum(credit)
WHERE customer_id in (21,22,23,24) AND no_download <> 1
GROUP BY reference_id, transaction_type_id ORDER BY created_at
I'm not sure you can do "ORDER BY created_at" and not include it in the select fields, but here is an example.
#history = AccountingTransaction.
select([:reference_id, :transaction_type_id, :created_at]).
select(AccountingTransaction.arel_table[:credit].sum.as("credit_sum")).
where("customer_id in (?) AND no_download <> 1", customers_in_account).
group(:transaction_type_id, :reference_id).
order(:created_at)
To access the credit_sum you could do:
#history[0].attributes["credit_sum"]
I guess if you'd like, you could create a method:
def credit_sum
attributes["credit_sum"]
end
EDIT *
As stated in comments you can access the attribute directly:
#history[0].credit_sum

Resources