diff --git a/publish-extensions.js b/publish-extensions.js index 932e566d5..2c71a6289 100644 --- a/publish-extensions.js +++ b/publish-extensions.js @@ -93,7 +93,7 @@ const flags = [ timeoutDelay = 5; } try { - /** @type {[PromiseSettledResult]} */ + /** @type {[PromiseSettledResult]} */ let [msExtension] = await Promise.allSettled([msGalleryApi.getExtension(extension.id, flags)]); if (msExtension.status === 'fulfilled') { context.msVersion = msExtension.value?.versions[0]?.version; @@ -106,7 +106,7 @@ const flags = [ } async function updateStat() { - /** @type {[PromiseSettledResult]} */ + /** @type {[PromiseSettledResult]} */ const [ovsxExtension] = await Promise.allSettled([openGalleryApi.getExtension(extension.id, flags)]); if (ovsxExtension.status === 'fulfilled') { context.ovsxVersion = ovsxExtension.value?.versions[0]?.version; @@ -138,10 +138,7 @@ const flags = [ } if (context.msVersion && context.msLastUpdated && monthAgo.getTime() <= context.msLastUpdated.getTime()) { - stat.hitMiss[extension.id] = { - ...extStat, - hit: typeof daysInBetween === 'number' && 0 < daysInBetween && daysInBetween <= 2 - } + stat.hitMiss[extension.id] = extStat; } } diff --git a/report-extensions.js b/report-extensions.js index 7368e74bb..f45da2cd5 100644 --- a/report-extensions.js +++ b/report-extensions.js @@ -37,7 +37,18 @@ function sortedKeys(s) { const notInMS = stat.notInMS.length; const total = upToDate + notInOpen + outdated + unstable + notInMS; const updatedInMTD = Object.keys(stat.hitMiss).length; - const updatedInOpen = Object.keys(stat.hitMiss).filter(id => stat.hitMiss[id].hit).length; + const updatedInOpenIn2Days = new Set(Object.keys(stat.hitMiss).filter(id => { + const { daysInBetween } = stat.hitMiss[id]; + return typeof daysInBetween === 'number' && 0 <= daysInBetween && daysInBetween <= 2; + })); + const updatedInOpenIn2Weeks = new Set(Object.keys(stat.hitMiss).filter(id => { + const { daysInBetween } = stat.hitMiss[id]; + return typeof daysInBetween === 'number' && 0 <= daysInBetween && daysInBetween <= 14; + })); + const updatedInOpenInMonth = new Set(Object.keys(stat.hitMiss).filter(id => { + const { daysInBetween } = stat.hitMiss[id]; + return typeof daysInBetween === 'number' && 0 <= daysInBetween && daysInBetween <= 30; + })); const msPublished = Object.keys(stat.msPublished).length; const totalResolutions = Object.keys(stat.resolutions).length; @@ -71,7 +82,9 @@ function sortedKeys(s) { summary += `Total resolved: ${totalResolved} (${(totalResolved / totalResolutions * 100).toFixed(0)}%)\r\n`; summary += `\r\n`; summary += `Updated in MS marketplace in month-to-date: ${updatedInMTD}\r\n`; - summary += `Of which updated in Open VSX within 2 days: ${updatedInOpen} (${(updatedInOpen / updatedInMTD * 100).toFixed(0)}%)\r\n`; + summary += `Of which updated in Open VSX within 2 days: ${updatedInOpenIn2Days.size} (${(updatedInOpenIn2Days.size / updatedInMTD * 100).toFixed(0)}%)\r\n`; + summary += `Of which updated in Open VSX within 2 weeks: ${updatedInOpenIn2Weeks.size} (${(updatedInOpenIn2Weeks.size / updatedInMTD * 100).toFixed(0)}%)\r\n`; + summary += `Of which updated in Open VSX within a month: ${updatedInOpenInMonth.size} (${(updatedInOpenInMonth.size / updatedInMTD * 100).toFixed(0)}%)\r\n`; summary += '-------------------\r\n'; console.log(summary); @@ -139,7 +152,10 @@ function sortedKeys(s) { content += '\r\n----- Updated in Open VSX within 2 days after in MS marketplace in MTD -----\r\n'; for (const id of sortedKeys(stat.hitMiss)) { const r = stat.hitMiss[id]; - content += `${r.hit ? '+' : '-'} ${id}: installs: ${r.msInstalls}; daysInBetween: ${r.daysInBetween?.toFixed(0)}; MS marketplace: ${r.msVersion}; Open VSX: ${r.openVersion}\r\n`; + const in2Days = updatedInOpenIn2Days.has(id) ? '+' : '-'; + const in2Weeks = updatedInOpenIn2Weeks.has(id) ? '+' : '-'; + const inMonth = updatedInOpenInMonth.has(id) ? '+' : '-'; + content += `${inMonth}${in2Weeks}${in2Days} ${id}: installs: ${r.msInstalls}; daysInBetween: ${r.daysInBetween?.toFixed(0)}; MS marketplace: ${r.msVersion}; Open VSX: ${r.openVersion}\r\n`; } content += '-------------------\r\n'; } diff --git a/types.d.ts b/types.d.ts index 50847abc1..40025412d 100644 --- a/types.d.ts +++ b/types.d.ts @@ -44,7 +44,7 @@ export interface PublishStat { [id: string]: MSExtensionStat } hitMiss: { - [id: string]: (ExtensionStat | ExtensionStat) & { hit: boolean } + [id: string]: (ExtensionStat | ExtensionStat) } }