Skip to content

Commit

Permalink
MWPW-155686 Catalog Milo: Preview Index Follow Up (#399)
Browse files Browse the repository at this point in the history
Co-authored-by: Bozo Jovicic <[email protected]>
  • Loading branch information
bozojovicic and Bozo Jovicic authored Aug 23, 2024
1 parent 242fe28 commit 8da5232
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
13 changes: 2 additions & 11 deletions .github/preview-index/src/indexFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
************************************************************************* */

const fetch = require('node-fetch-commonjs');
const { getConfig, getResourceIndexData, getItemId, sharepointHeaders, edsAdminHeaders } = require('./sharepoint');
const { getConfig, getResourceIndexData, getItemId, sharepointHeaders, edsAdminHeaders, previewIndex } = require('./sharepoint');

const config = getConfig();

Expand Down Expand Up @@ -141,16 +141,7 @@ const reindex = async () => {
console.log(`Failed to add index rows: ${response.status} - ${response.statusText}`);
}

console.log('preview update url:' + config.PREVIEW_UPDATE_URL);
const previewResponse = await fetch(config.PREVIEW_UPDATE_URL, {
method: 'POST',
headers: edsAdminHeaders(),
});
if (previewResponse?.ok) {
console.log(`Previewed index file: ${previewResponse.status} - ${previewResponse.statusText}`);
} else {
console.log(`Failed to preview index file: ${previewResponse.status} - ${previewResponse.statusText}`);
}
await previewIndex();
console.log(`Reindexed folder ${folder}`);
};

Expand Down
3 changes: 2 additions & 1 deletion .github/preview-index/src/indexSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
************************************************************************* */

const fetch = require('node-fetch-commonjs');
const { getConfig, getResourceIndexData, getAccessToken, getItemId, sharepointHeaders } = require('./sharepoint');
const { getConfig, getResourceIndexData, getAccessToken, getItemId, sharepointHeaders, previewIndex } = require('./sharepoint');

const config = getConfig();

Expand Down Expand Up @@ -186,6 +186,7 @@ const reindex = async () => {
await addTableRow(itemId, resData);
}

await previewIndex();
}

reindex();
16 changes: 15 additions & 1 deletion .github/preview-index/src/sharepoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,25 @@ const getItemId = async (indexPath) => {
return null;
};

const previewIndex = async () => {
console.log('Preview update url: ' + PREVIEW_UPDATE_URL);
const previewResponse = await fetch(PREVIEW_UPDATE_URL, {
method: 'POST',
headers: edsAdminHeaders(),
});
if (previewResponse?.ok) {
console.log(`Previewed index file: ${previewResponse.status} - ${previewResponse.statusText}`);
} else {
console.log(`Failed to preview index file: ${previewResponse.status} - ${previewResponse.statusText}`);
}
}

module.exports = {
getConfig,
getResourceIndexData,
getAccessToken,
getItemId,
sharepointHeaders,
edsAdminHeaders
edsAdminHeaders,
previewIndex
};

0 comments on commit 8da5232

Please sign in to comment.