Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions devboard/client/src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from "../components/common/Icons";
import { openVisit, touchVisit } from "../utils/lastVisit";
import { timeAgo } from "../utils/timeAgo";
import { topLanguage } from "../utils/topLanguage";
import {
BoardZoomContext,
ZOOM_MAX,
Expand Down Expand Up @@ -282,6 +283,8 @@ const Dashboard = () => {
};

const debt = calculateDebtScore();
const topLang = useMemo(() => topLanguage(tasks), [tasks]);

const [streak, setStreak] = useState(calculateStreak);
const [showBurndown, setShowBurndown] = useState(false);
const [standupCopied, setStandupCopied] = useState(false);
Expand Down Expand Up @@ -1578,6 +1581,15 @@ ${stuck
{streak} day streak
</span>
)}
{topLang && (
<span
title={`${topLang.count} of ${topLang.total} ${topLang.total === 1 ? "snippet is" : "snippets are"} ${topLang.language}`}
className="text-xs font-mono-code text-zinc-400 hidden 2xl:inline"
>
mostly {topLang.language}
</span>
)}

{debt.count > 0 && (
<span
title={`Tech Debt Level: ${debt.level} (${debt.count} active)`}
Expand Down
22 changes: 22 additions & 0 deletions devboard/client/src/utils/topLanguage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// The snippet language used most across the board, or null when there are no
// snippets. Ties go to the alphabetically first language so the badge does not
// flip between renders.
export const topLanguage = (tasks) => {
const counts = {};
let total = 0;
for (const task of tasks || []) {
for (const snippet of task.snippets || []) {
const language = String(snippet?.language || "")
.trim()
.toLowerCase();
if (!language) continue;
counts[language] = (counts[language] || 0) + 1;
total += 1;
}
}
const [language, count] =
Object.entries(counts).sort(
(a, b) => b[1] - a[1] || a[0].localeCompare(b[0]),
)[0] || [];
return language ? { language, count, total } : null;
};
Loading