How to get list of space and page watches for a user
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
To get all the space and page watches of a user from the database.
Solution
The following queries have been tested in PostGreSQL
Get Page Watches - Replace <user_name> with actual username
SELECT c.contentid, c.title, s.spacekey
FROM CONTENT c
JOIN SPACES s
ON c.spaceid = s.spaceid
JOIN NOTIFICATIONS n
ON c.contentid = n.contentid
JOIN user_mapping um
ON n.username = um.user_key
WHERE um.username = '<user_name>';
Get Space Watches - Replace <user_name> with actual username
SELECT s.spaceid, s.spacekey, s.spacename
FROM SPACES s
JOIN NOTIFICATIONS n
ON s.spaceid = n.spaceid
JOIN user_mapping um
ON n.username = um.user_key
WHERE um.username = '<user_name>';