Address code review feedback: env var config, filter PRs by date, real activity heatmap
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
This commit is contained in:
6
.github/workflows/digest-bot.yml
vendored
6
.github/workflows/digest-bot.yml
vendored
@@ -7,6 +7,11 @@ on:
|
|||||||
|
|
||||||
# Allow manual trigger for testing
|
# Allow manual trigger for testing
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
digest_issue:
|
||||||
|
description: 'Issue number to post digest to (overrides default)'
|
||||||
|
required: false
|
||||||
|
type: number
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
weekly-digest:
|
weekly-digest:
|
||||||
@@ -27,5 +32,6 @@ jobs:
|
|||||||
- name: 📊 Run Weekly Digest Bot
|
- name: 📊 Run Weekly Digest Bot
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
DIGEST_ISSUE: ${{ inputs.digest_issue || '' }}
|
||||||
run: node digest.js
|
run: node digest.js
|
||||||
working-directory: ./bot
|
working-directory: ./bot
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ const https = require("https");
|
|||||||
// 🔧 Configuration
|
// 🔧 Configuration
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
// 📝 UPDATE THIS: Set to the issue number where digests will be posted
|
// 📝 Set via DIGEST_ISSUE env var or update the default value below
|
||||||
// e.g., if your "📊 Agent Weekly Digest Thread" issue is #7, set DIGEST_ISSUE=7
|
// e.g., if your "📊 Agent Weekly Digest Thread" issue is #7, set DIGEST_ISSUE=7
|
||||||
const DIGEST_ISSUE = 1;
|
const DIGEST_ISSUE = parseInt(process.env.DIGEST_ISSUE, 10) || 1;
|
||||||
|
|
||||||
const REPO_OWNER = process.env.GITHUB_REPOSITORY_OWNER || "BlackRoad-OS";
|
const REPO_OWNER = process.env.GITHUB_REPOSITORY_OWNER || "BlackRoad-OS";
|
||||||
const REPO_NAME = process.env.GITHUB_REPOSITORY?.split("/")[1] || "blackroad-os";
|
const REPO_NAME = process.env.GITHUB_REPOSITORY?.split("/")[1] || "blackroad-os";
|
||||||
@@ -297,7 +297,14 @@ async function fetchWeeklyActivity() {
|
|||||||
function processActivityData(data) {
|
function processActivityData(data) {
|
||||||
const repo = data.repository;
|
const repo = data.repository;
|
||||||
const issues = repo.issues.nodes;
|
const issues = repo.issues.nodes;
|
||||||
const pullRequests = repo.pullRequests.nodes;
|
|
||||||
|
// Filter PRs to only include those from the past week
|
||||||
|
const oneWeekAgo = new Date();
|
||||||
|
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
|
||||||
|
const pullRequests = repo.pullRequests.nodes.filter((pr) => {
|
||||||
|
const createdAt = new Date(pr.createdAt);
|
||||||
|
return createdAt >= oneWeekAgo;
|
||||||
|
});
|
||||||
|
|
||||||
// Issue statistics
|
// Issue statistics
|
||||||
const openIssues = issues.filter((i) => i.state === "OPEN").length;
|
const openIssues = issues.filter((i) => i.state === "OPEN").length;
|
||||||
@@ -319,16 +326,20 @@ function processActivityData(data) {
|
|||||||
const closeTimes = closedIssuesList.map((i) => daysBetween(i.createdAt, i.closedAt));
|
const closeTimes = closedIssuesList.map((i) => daysBetween(i.createdAt, i.closedAt));
|
||||||
const avgCloseTime = calculateAverage(closeTimes);
|
const avgCloseTime = calculateAverage(closeTimes);
|
||||||
|
|
||||||
// Top contributors
|
// Top contributors (filter out null authors)
|
||||||
const contributorCounts = {};
|
const contributorCounts = {};
|
||||||
for (const issue of issues) {
|
for (const issue of issues) {
|
||||||
const author = issue.author?.login || "unknown";
|
const author = issue.author?.login;
|
||||||
|
if (author) {
|
||||||
contributorCounts[author] = (contributorCounts[author] || 0) + 1;
|
contributorCounts[author] = (contributorCounts[author] || 0) + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (const pr of pullRequests) {
|
for (const pr of pullRequests) {
|
||||||
const author = pr.author?.login || "unknown";
|
const author = pr.author?.login;
|
||||||
|
if (author) {
|
||||||
contributorCounts[author] = (contributorCounts[author] || 0) + 1;
|
contributorCounts[author] = (contributorCounts[author] || 0) + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const topContributors = Object.entries(contributorCounts)
|
const topContributors = Object.entries(contributorCounts)
|
||||||
.sort((a, b) => b[1] - a[1])
|
.sort((a, b) => b[1] - a[1])
|
||||||
@@ -352,16 +363,18 @@ function processActivityData(data) {
|
|||||||
statusBreakdown[status] = (statusBreakdown[status] || 0) + 1;
|
statusBreakdown[status] = (statusBreakdown[status] || 0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weekly activity heatmap (mock data for now - would need commit data)
|
// Weekly activity heatmap based on actual issue/PR creation dates
|
||||||
const weeklyActivity = {
|
const weeklyActivity = { Mon: 0, Tue: 0, Wed: 0, Thu: 0, Fri: 0, Sat: 0, Sun: 0 };
|
||||||
Mon: Math.floor(Math.random() * 15),
|
const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||||
Tue: Math.floor(Math.random() * 15),
|
|
||||||
Wed: Math.floor(Math.random() * 15),
|
for (const issue of issues) {
|
||||||
Thu: Math.floor(Math.random() * 15),
|
const day = dayNames[new Date(issue.createdAt).getDay()];
|
||||||
Fri: Math.floor(Math.random() * 15),
|
weeklyActivity[day]++;
|
||||||
Sat: Math.floor(Math.random() * 5),
|
}
|
||||||
Sun: Math.floor(Math.random() * 5),
|
for (const pr of pullRequests) {
|
||||||
};
|
const day = dayNames[new Date(pr.createdAt).getDay()];
|
||||||
|
weeklyActivity[day]++;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
issues: {
|
issues: {
|
||||||
|
|||||||
Reference in New Issue
Block a user