How to check Cloud Confluence space last modified

Jack Hsia November 16, 2017

Hi All,

Does any one know how to check when is a space in cloud version was last modified?

 

Trying to archive the unused spaces to tidy up our confluence, but found it difficult to do so.

 

Thanks.

 

BR,

Jack Hsia

2 answers

2 votes
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

I would assume that you are referring to when some action was performed in that space. Here's something I threw together real quick that will show the time when a page was last modified in that space. You can run it by pasting it into your browser console while you are logged into Confluence (usually brought up by pressing F12 or look for Developer tools in the browser menu) and it will return a list of spaces with the last modified date (should work for both Server and Cloud):

jQuery.ajax({dataType: 'json',
contentType: 'application/json',
type: 'POST',
url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getSpaces',
success: function(spaces) {
jQuery(spaces).each(function() {
var space = this;
if (space.type === "global") {
jQuery.ajax({
url: contextPath + '/rest/api/content/search?cql=space%3D' + space.key + '%20and%20type%3Dpage%20order%20by%20lastmodified%20desc&expand=version&limit=1',
success: function(data) {
console.log(space.name + "(" + space.key + ") - " + data.results[0].version.when);
}
});
}
});
}
});

 Also, if you're interested in managing pages better on your Confluence Cloud instance, you may want to check out Space Timeline, which allows you to manage pages easier.

Jack Hsia November 16, 2017

Hi Stephen, 

 

Thank you very much for your help. 

It works very well. 

You've made my day.

 

Thanks again.

Jack

Bojana July 27, 2020

Hi @Stephen Deutsch & @Jack Hsia 

I am looking for the same solution for cloud instance, is your code above still valid? I have tried to run it but getting errors...

Many thanks in advance! :)

Alex K February 15, 2022

Hi @Stephen Deutsch ,

 

I'm also looking for this functionality, code threw errors and no results. do let us know if you have modified solution.

Like Rob Reynolds likes this
0 votes
Zdeněk September 20, 2023

I managed to get most of the space last updated dates via this script you cna put into browser console: 

var spaceInfo = {};
var currentPage = 1;
var pageSize = 50; // Adjust as needed, depending on your space count

// Function to fetch space details
function fetchSpaceDetails(spaceKey) {
return new Promise((resolve, reject) => {
jQuery.ajax({
url: contextPath + '/rest/api/content/search?cql=space%3D' + spaceKey + '%20and%20type%3Dpage%20order%20by%20lastmodified%20desc&expand=version&limit=1',
success: function (data) {
if (data.results && data.results.length > 0 && data.results[0].version) {
var lastUpdated = data.results[0].version.when;
resolve(lastUpdated);
} else {
reject(new Error("Space details not found for " + spaceKey));
}
},
error: function (error) {
reject(error);
}
});
});
}

// Function to fetch spaces page by page
function fetchSpacesPage(page) {
jQuery.ajax({
dataType: 'json',
contentType: 'application/json',
type: 'GET',
url: contextPath + '/rest/api/space',
data: {
limit: pageSize,
start: (page - 1) * pageSize
},
success: function (spaces) {
var totalSpaces = spaces.size;
spaceInfo.totalSpaces = totalSpaces;

jQuery(spaces.results).each(async function () {
var space = this;
if (space.type === "global") {
try {
var lastUpdated = await fetchSpaceDetails(space.key);
spaceInfo[space.key] = {
name: space.name,
lastUpdated: lastUpdated
};
console.log(space.name + " (" + space.key + ") - " + lastUpdated);
} catch (error) {
console.error(error.message);
}
}
});

if ((page * pageSize) < totalSpaces) {
fetchSpacesPage(page + 1);
}
},
error: function (error) {
console.error("Error fetching spaces: " + error.statusText);
}
});
}

fetchSpacesPage(currentPage);

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events