For a given list of projects, find the roles in that project, who the users are in that role, including who the groups are in that role
looking for SQL query for this.
Hi Micky,
Thank you for the solution But i tried the same in sql server its not working. moreover I don't want to restrict the role as only admins.
I tried the below query but I dnt think its giving the right result If u can suggest anything on this.
select cwd_group.group_name, cwd_user.user_name, cwd_user.display_name, cwd_user.email_address,
(select attribute_value from cwd_user_attribute where cwd_user_attribute.user_id = cwd_user.id and cwd_user_attribute.attribute_name = "lastAuthenticated") as lastAuthenticated from cwd_membership left join cwd_user on cwd_user.id = cwd_membership.child_user_id left join cwd_group on cwd_membership.parent_id = cwd_group.id order by user_name asc;
Hi Neha,
If you want to read from DB that's OK and you should look at the cwd_membership table which holds relationships between users and groups. Regarding the project roles, the table is projectroleactor (associating roles with actors of type user or group) and projectrole which is the list of available project roles.
here is a query I've used to extract project with their admins. The projectroleid filter can be removed/updated to suit your needs:
SELECT p.id AS 'PID',
pkey AS 'Key',
p.pname 'Name',
ISNULL(u.display_name,'') AS 'Lead',
ISNULL((SELECT COUNT(*) FROM jiraissue GROUP BY project HAVING project = p.ID),0) AS 'Issues',
p.projecttype AS 'Type',
ISNULL((SELECT cname FROM projectcategory WHERE id = (SELECT sink_node_id FROM nodeassociation WHERE source_node_id = p.id AND association_type='ProjectCategory')),'') AS 'Category',
LEFT((
SELECT CONCAT(roletypeparameter, ' (',REPLACE(REPLACE(roletype,'atlassian-',''),'-role-actor',''),')')+', ' AS "text()"
FROM projectroleactor
WHERE pid = p.id AND projectroleid = 10002 AND roletypeparameter <> 'jira-administrators'
FOR XML PATH('')
),255) AS 'Admins'
FROM project p
LEFT JOIN app_user au ON au.user_key = p.lead
LEFT JOIN cwd_user u ON u.lower_user_name = au.lower_user_name
Please note that the query is designed for SQL Server and might be adapted for your database server.
Hope this helps!
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Micky,
Thank you for the solution But i tried the same in sql server its not working. moreover I don't want to restrict the role as only admins.
I tried the below query but I dnt think its giving the right result If u can suggest anything on this.
select cwd_group.group_name, cwd_user.user_name, cwd_user.display_name, cwd_user.email_address,
(select attribute_value from cwd_user_attribute where cwd_user_attribute.user_id = cwd_user.id and cwd_user_attribute.attribute_name = "lastAuthenticated") as lastAuthenticated from cwd_membership left join cwd_user on cwd_user.id = cwd_membership.child_user_id left join cwd_group on cwd_membership.parent_id = cwd_group.id order by user_name asc;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.