Skip to content

Commit

Permalink
report diff to MS for MTD in 2 weeks and month as well
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Nov 30, 2021
1 parent fd52c22 commit 2baee1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
9 changes: 3 additions & 6 deletions publish-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const flags = [
timeoutDelay = 5;
}
try {
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
let [msExtension] = await Promise.allSettled([msGalleryApi.getExtension(extension.id, flags)]);
if (msExtension.status === 'fulfilled') {
context.msVersion = msExtension.value?.versions[0]?.version;
Expand All @@ -106,7 +106,7 @@ const flags = [
}

async function updateStat() {
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
const [ovsxExtension] = await Promise.allSettled([openGalleryApi.getExtension(extension.id, flags)]);
if (ovsxExtension.status === 'fulfilled') {
context.ovsxVersion = ovsxExtension.value?.versions[0]?.version;
Expand Down Expand Up @@ -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;
}
}

Expand Down
22 changes: 19 additions & 3 deletions report-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <= Math.round(daysInBetween) && Math.round(daysInBetween) <= 2;
}));
const updatedInOpenIn2Weeks = new Set(Object.keys(stat.hitMiss).filter(id => {
const { daysInBetween } = stat.hitMiss[id];
return typeof daysInBetween === 'number' && 0 <= Math.round(daysInBetween) && Math.round(daysInBetween) <= 14;
}));
const updatedInOpenInMonth = new Set(Object.keys(stat.hitMiss).filter(id => {
const { daysInBetween } = stat.hitMiss[id];
return typeof daysInBetween === 'number' && 0 <= Math.round(daysInBetween) && Math.round(daysInBetween) <= 30;
}));
const msPublished = Object.keys(stat.msPublished).length;

const totalResolutions = Object.keys(stat.resolutions).length;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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';
}
Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface PublishStat {
[id: string]: MSExtensionStat
}
hitMiss: {
[id: string]: (ExtensionStat | ExtensionStat) & { hit: boolean }
[id: string]: (ExtensionStat | ExtensionStat)
}
}

Expand Down

0 comments on commit 2baee1c

Please sign in to comment.