diff --git a/.github/workflows/issue-notifier.yml b/.github/workflows/issue-notifier.yml index 2639fdb7b1..afef50a48b 100644 --- a/.github/workflows/issue-notifier.yml +++ b/.github/workflows/issue-notifier.yml @@ -50,7 +50,7 @@ jobs: - name: Collect Issue Data id: collect - run: npx ts-node ./scripts/issues-scraper/index.ts + run: npx tsx ./scripts/issues-scraper/index.ts env: GITHUB_TOKEN: ${{ github.token }} diff --git a/scripts/issues-scraper/format-slack-message.ts b/scripts/issues-scraper/format-slack-message.ts index 4b299b9433..25212ccbbb 100644 --- a/scripts/issues-scraper/format-slack-message.ts +++ b/scripts/issues-scraper/format-slack-message.ts @@ -3,7 +3,6 @@ import { table } from 'markdown-factory'; export function getSlackMessageJson(body: string) { return { - text: 'Some Text', blocks: [ { type: 'section', @@ -19,8 +18,7 @@ export function getSlackMessageJson(body: string) { export function formatGhReport( currentData: ReportData, trendData: TrendData, - prevData: ReportData, - unlabeledIssuesUrl: string + prevData: ReportData ): string { const issueDelta = trendData.totalIssueCount; const formattedIssueDelta = formatDelta(issueDelta); @@ -28,7 +26,7 @@ export function formatGhReport( const bugDelta = trendData.totalBugCount; const formattedBugDelta = formatDelta(bugDelta); - const header = `Issue Report for ${currentData.collectedDate} <${unlabeledIssuesUrl}|[view unlabeled]> + const header = `Issue Report for ${currentData.collectedDate} \`\`\` Totals, Issues: ${currentData.totalIssueCount} ${formattedIssueDelta} Bugs: ${currentData.totalBugCount} ${formattedBugDelta}\n\n`; diff --git a/scripts/issues-scraper/index.ts b/scripts/issues-scraper/index.ts index 65cf164335..69bec7e4f9 100644 --- a/scripts/issues-scraper/index.ts +++ b/scripts/issues-scraper/index.ts @@ -1,11 +1,10 @@ import { ensureDirSync, readJsonSync, writeJsonSync } from 'fs-extra'; import { dirname, join } from 'path'; import { ReportData, ScopeData, TrendData } from './model'; -import { getScopeLabels, scrapeIssues } from './scrape-issues'; +import { scrapeIssues } from './scrape-issues'; import { formatGhReport, getSlackMessageJson } from './format-slack-message'; import { setOutput } from '@actions/core'; import isCI from 'is-ci'; -import { readdirSync } from 'fs'; const CACHE_FILE = join(__dirname, 'cached', 'data.json'); @@ -15,12 +14,7 @@ async function main() { oldData.collectedDate ? new Date(oldData.collectedDate) : undefined ); const trendData = getTrendData(currentData, oldData); - const formatted = formatGhReport( - currentData, - trendData, - oldData, - getUnlabeledIssuesUrl(await getScopeLabels()) - ); + const formatted = formatGhReport(currentData, trendData, oldData); setOutput('SLACK_MESSAGE', getSlackMessageJson(formatted)); console.log(formatted.replace(/\<(.*)\|(.*)\>/g, '[$1]($0)')); saveCacheData(currentData); @@ -47,7 +41,7 @@ function getTrendData(newData: ReportData, oldData: ReportData): TrendData { scopes: scopeTrends as Record, totalBugCount: newData.totalBugCount - oldData.totalBugCount, totalIssueCount: newData.totalIssueCount - oldData.totalIssueCount, - totalClosed: newData.totalClosed - oldData.totalClosed ?? 0, + totalClosed: newData.totalClosed - oldData.totalClosed, untriagedIssueCount: newData.untriagedIssueCount - oldData.untriagedIssueCount, }; @@ -62,10 +56,8 @@ function saveCacheData(report: ReportData) { function getOldData(): ReportData { try { - console.log('DIR CONTENTS:', readdirSync(dirname(CACHE_FILE))); return readJsonSync(CACHE_FILE); } catch (e) { - console.log(e); return { scopes: {}, totalBugCount: 0, @@ -75,10 +67,3 @@ function getOldData(): ReportData { }; } } - -function getUnlabeledIssuesUrl(scopeLabels: string[]) { - const labelFilters = scopeLabels.map((s) => `-label:"${s}"`); - return `https://github.com/nrwl/nx/issues/?q=is%3Aopen+is%3Aissue+sort%3Aupdated-desc+${encodeURIComponent( - labelFilters.join(' ') - )}`; -}