This should only show the number of pages visible to you, the current user.

This page is to check against SiteImprove indexing results. Please talk to Helen Setchell before you update/move/delete it.

<div id="publicSpacesTable">Loading...</div>
Aeolus 8
Atlas 11
BUFRDC 17
CKDMIP 13
Copernicus Knowledge Base 28
Copernicus Services 9
Copernicus User Support Forum 0
Data and Charts 17
ECaccess 30
ecCodes 27
ecFlow 31
ECMWF Events 0
ECMWF Radiation Scheme 8
ECMWF Web API 42
Emoslib 28
European Weather Cloud KB 26
fcKit 4
Forecast User 34
Forecast User Guide 137
GRIB-API 0
LDAS 2
LEXIS Project 0
Magics 1
Metview 2
ODB API 0
OpenIFS 0
OpenIFS User Forums 0
Pages not currently in a content group 260
RMDCN NG 0
ROM SAF reanalysis 5
S2S 1
Software Support 18
TAC to BUFR Migration 0
TIGGE 1
TIGGE-LAM 1
Training 7
UERRA 35
User Documentation 143
WIGOSWT 6
WMO Lead Centre for Deterministic NWP Verification (LC-DNV) 0
WMO Lead Centre for Wave Forecast Verification (LC-WFV) 0
WSIM 0
YOPP 1
<style>
  #publicSpacesTable table tr:nth-child(even) {
    background-color: #f9f9f9;
  }
</style>

<script>
(async function() {
  const tableContainer = document.getElementById('publicSpacesTable');
  tableContainer.innerHTML = 'Fetching public spaces...';

  async function fetchPublicSpaces(start = 0, limit = 50, accumulated = []) {
    const res = await fetch(`/rest/api/space?label=public&limit=${limit}&start=${start}`);
    const data = await res.json();
    const all = accumulated.concat(data.results);
    if (data._links.next) {
      return fetchPublicSpaces(start + limit, limit, all);
    }
    return all;
  }

  async function countPagesInSpace(spaceKey) {
    const res = await fetch(`/rest/api/search?cql=space=${spaceKey}+AND+type=page&limit=1`);
    const data = await res.json();
    return data.totalSize || 0;
  }

  try {
    const publicSpaces = await fetchPublicSpaces();

    if (publicSpaces.length === 0) {
      tableContainer.innerHTML = '<p>No public spaces found.</p>';
      return;
    }

    // Now fetch page counts in parallel
    const results = await Promise.all(publicSpaces.map(async space => {
      const pageCount = await countPagesInSpace(space.key);
      return {
        name: space.name,
        link: space._links.webui,
        count: pageCount
      };
    }));

    // Build table
    const table = document.createElement('table');
    table.style.borderCollapse = 'collapse';
    table.style.width = '100%';

    const headerRow = table.insertRow();
    ['Space Name', 'Page Count'].forEach(text => {
      const th = document.createElement('th');
      th.innerText = text;
      th.style.borderBottom = '1px solid #ccc';
      th.style.textAlign = 'left';
      th.style.padding = '6px';
      headerRow.appendChild(th);
    });

    for (const space of results) {
      const row = table.insertRow();

      const nameCell = row.insertCell();
      const link = document.createElement('a');
      link.href = space.link;
      link.target = '_blank';
      link.innerText = space.name;
      nameCell.appendChild(link);
      nameCell.style.padding = '6px';

      const countCell = row.insertCell();
      countCell.innerText = space.count;
      countCell.style.padding = '6px';
    }

    tableContainer.innerHTML = '';
    tableContainer.appendChild(table);
  } catch (error) {
    console.error(error);
    tableContainer.innerHTML = 'Error fetching public spaces.';
  }
})();
</script>