Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix(interviews): sort undated rounds last, restyle the row badges, move the sidebar entry after Jobs

Khuram Niaz5068b50b1277
diff --git a/__tests__/interview.actions.spec.ts b/__tests__/interview.actions.spec.ts
index 28fd8ad..dce9e64 100644
--- a/__tests__/interview.actions.spec.ts
+++ b/__tests__/interview.actions.spec.ts
@@ -22,7 +22,8 @@ beforeEach(() => {
vi.clearAllMocks();
(getCurrentUser as any).mockResolvedValue(user);
db.jobStage.findMany.mockResolvedValue([]);
- db.jobStage.count.mockResolvedValue(0);
+ // Non-zero, so the dated page is actually queried
+ db.jobStage.count.mockResolvedValue(1);
});
describe("getInterviewList", () => {
@@ -34,7 +35,7 @@ describe("getInterviewList", () => {
expect(where.StageType).toEqual({ Status: { value: "interview" } });
});
- it("treats undated rounds as upcoming and orders them first", async () => {
+ it("treats undated rounds as upcoming and orders them last", async () => {
await getInterviewList("upcoming");
const args = db.jobStage.findMany.mock.calls[0][0];
@@ -42,48 +43,66 @@ describe("getInterviewList", () => {
{ occurredAt: { gte: expect.any(Date) } },
{ occurredAt: null },
]);
- // SQLite sorts NULL first on ASC, which is what puts undated rounds on top
+ // The paged query is the dated half; soonest first
+ expect(args.where.AND).toContainEqual({ occurredAt: { not: null } });
expect(args.orderBy[0]).toEqual({ occurredAt: "asc" });
});
it("orders past rounds newest first over a set with no undated rows", async () => {
+ db.jobStage.count.mockResolvedValue(1);
+
await getInterviewList("past");
const args = db.jobStage.findMany.mock.calls[0][0];
+ // The dated split is an AND, so the past window survives it
expect(args.where.occurredAt).toEqual({ lt: expect.any(Date) });
expect(args.where.OR).toBeUndefined();
expect(args.orderBy[0]).toEqual({ occurredAt: "desc" });
+ // total === datedTotal, so no second query for undated rows
+ expect(db.jobStage.findMany).toHaveBeenCalledTimes(1);
});
- it("pins undated rounds to page 1 of the All view", async () => {
+ it("appends undated rounds after the dated ones", async () => {
db.jobStage.findMany
.mockResolvedValueOnce([{ id: "dated" }])
.mockResolvedValueOnce([{ id: "undated" }]);
- db.jobStage.count.mockResolvedValue(2);
+ // total 2, dated 1
+ db.jobStage.count.mockResolvedValueOnce(2).mockResolvedValueOnce(1);
const res = await getInterviewList("all", 1);
- // The paged query excludes NULLs; SQLite sorts them last on DESC, which
- // would otherwise strand them on the final page.
- expect(db.jobStage.findMany.mock.calls[0][0].where.occurredAt).toEqual({
- not: null,
+ expect(db.jobStage.findMany.mock.calls[0][0].where.AND).toContainEqual({
+ occurredAt: { not: null },
});
- expect(db.jobStage.findMany.mock.calls[1][0].where.occurredAt).toBeNull();
- expect(res.data.map((r: any) => r.id)).toEqual(["undated", "dated"]);
+ expect(db.jobStage.findMany.mock.calls[1][0].where.AND).toContainEqual({
+ occurredAt: null,
+ });
+ expect(res.data.map((r: any) => r.id)).toEqual(["dated", "undated"]);
expect(res.total).toBe(2);
});
- it("does not re-fetch the pinned rows on later pages", async () => {
- await getInterviewList("all", 2);
+ it("pages past the dated rows straight into the undated ones", async () => {
+ // 30 dated rows, 5 undated; page 2 of 25 is the tail of both
+ db.jobStage.count.mockResolvedValueOnce(35).mockResolvedValueOnce(30);
+ db.jobStage.findMany.mockResolvedValue([]);
- expect(db.jobStage.findMany).toHaveBeenCalledTimes(1);
+ await getInterviewList("all", 2, 25);
+
+ expect(db.jobStage.findMany.mock.calls[0][0]).toMatchObject({
+ skip: 25,
+ take: 5,
+ });
+ expect(db.jobStage.findMany.mock.calls[1][0]).toMatchObject({
+ skip: 0,
+ take: 25,
+ });
});
it("filters by round, company and search together", async () => {
await getInterviewList("all", 1, 25, "acme", "type-1", "co-1");
const where = db.jobStage.findMany.mock.calls[0][0].where;
- expect(where.AND).toEqual([
+ expect(where.AND.slice(0, 3)).toEqual([
{ stageTypeId: "type-1" },
{ Job: { companyId: "co-1" } },
{
diff --git a/__tests__/interviewDisplay.spec.ts b/__tests__/interviewDisplay.spec.ts
index 3ff7ea6..eea20c5 100644
--- a/__tests__/interviewDisplay.spec.ts
+++ b/__tests__/interviewDisplay.spec.ts
@@ -1,6 +1,6 @@
import {
outcomeLabel,
- outcomeTone,
+ outcomeColor,
formatIconKind,
formatText,
durationLabel,
@@ -39,13 +39,18 @@ describe("outcomeLabel", () => {
});
});
-describe("outcomeTone", () => {
- it("marks a bad ending destructive and a good one default", () => {
- expect(outcomeTone("Failed")).toBe("destructive");
- expect(outcomeTone("No-show")).toBe("destructive");
- expect(outcomeTone("Passed")).toBe("default");
- expect(outcomeTone("Scheduled")).toBe("outline");
- expect(outcomeTone("Not scheduled")).toBe("secondary");
+describe("outcomeColor", () => {
+ it("colours a bad ending red and a good one emerald", () => {
+ expect(outcomeColor("Failed")).toBe("red");
+ expect(outcomeColor("No-show")).toBe("red");
+ expect(outcomeColor("Passed")).toBe("emerald");
+ expect(outcomeColor("Scheduled")).toBe("blue");
+ expect(outcomeColor("Awaiting outcome")).toBe("amber");
+ expect(outcomeColor("Not scheduled")).toBe("slate");
+ });
+
+ it("falls back to slate for an unrecognised label", () => {
+ expect(outcomeColor("Something else")).toBe("slate");
});
});
diff --git a/src/actions/interview.actions.ts b/src/actions/interview.actions.ts
index 578a18b..dae8802 100644
--- a/src/actions/interview.actions.ts
+++ b/src/actions/interview.actions.ts
@@ -57,9 +57,8 @@ const buildInterviewWhere = (
return where;
};
-// Ordering stays in the query because the list is server-paged. SQLite sorts
-// NULL first on ASC, which is exactly the undated-first rule the Upcoming view
-// wants, and the Past view's set holds no NULLs at all.
+// Ordering stays in the query because the list is server-paged. This orders
+// the dated rows only; undated rounds are paged separately after them.
const interviewOrderBy = (view: InterviewView) =>
view === "upcoming"
? [{ occurredAt: "asc" as const }, { createdAt: "asc" as const }]
@@ -85,32 +84,44 @@ export const getInterviewList = async (
companyId,
);
- // On DESC, SQLite sorts NULL last, which would bury every unscheduled
- // round on the final page. All pages dated rows and pins the rest to 1.
- const pinUndated = view === "all";
- const pagedWhere = pinUndated
- ? { ...where, occurredAt: { not: null } }
- : where;
-
- const [rows, total, pinned] = await Promise.all([
- prisma.jobStage.findMany({
- where: pagedWhere,
- skip: (page - 1) * limit,
- take: limit,
- include: INTERVIEW_LIST_INCLUDE,
- orderBy: interviewOrderBy(view),
- }),
+ // Undated rounds sort last in every view. SQLite has no NULLS LAST and
+ // Prisma's `nulls` option is unsupported there, so the dated rows are
+ // paged first and the undated ones continue the list once they run out.
+ const and = where.AND ?? [];
+ const datedWhere = { ...where, AND: [...and, { occurredAt: { not: null } }] };
+ const undatedWhere = { ...where, AND: [...and, { occurredAt: null }] };
+ const skip = (page - 1) * limit;
+
+ const [total, datedTotal] = await Promise.all([
prisma.jobStage.count({ where }),
- pinUndated && page === 1
- ? prisma.jobStage.findMany({
- where: { ...where, occurredAt: null },
+ prisma.jobStage.count({ where: datedWhere }),
+ ]);
+
+ const datedTake = Math.min(limit, Math.max(0, datedTotal - skip));
+ const dated =
+ datedTake > 0
+ ? await prisma.jobStage.findMany({
+ where: datedWhere,
+ skip,
+ take: datedTake,
+ include: INTERVIEW_LIST_INCLUDE,
+ orderBy: interviewOrderBy(view),
+ })
+ : [];
+
+ const undatedTake = limit - dated.length;
+ const undated =
+ undatedTake > 0 && total > datedTotal
+ ? await prisma.jobStage.findMany({
+ where: undatedWhere,
+ skip: Math.max(0, skip - datedTotal),
+ take: undatedTake,
include: INTERVIEW_LIST_INCLUDE,
orderBy: { createdAt: "desc" },
})
- : Promise.resolve([]),
- ]);
+ : [];
- return { data: [...pinned, ...rows], total };
+ return { data: [...dated, ...undated], total };
} catch (error) {
return handleError(error, "Failed to fetch interviews. ");
}
diff --git a/src/components/interviews/InterviewRow.tsx b/src/components/interviews/InterviewRow.tsx
index 885539e..e5b6e28 100644
--- a/src/components/interviews/InterviewRow.tsx
+++ b/src/components/interviews/InterviewRow.tsx
@@ -12,7 +12,7 @@ import {
Phone,
Video,
} from "lucide-react";
-import { Badge } from "../ui/badge";
+import { StatusBadge } from "../StatusBadge";
import { Button } from "../ui/button";
import {
DropdownMenu,
@@ -31,7 +31,7 @@ import {
formatText,
interviewerSummary,
outcomeLabel,
- outcomeTone,
+ outcomeColor,
prepSummary,
whenParts,
} from "./interviewDisplay";
@@ -88,7 +88,7 @@ function InterviewRow({
)}
</Button>
</TableCell>
- <TableCell>
+ <TableCell className="whitespace-nowrap">
<div className="font-medium">{when.day}</div>
{when.time && (
<div className="text-xs text-muted-foreground">{when.time}</div>
@@ -106,9 +106,13 @@ function InterviewRow({
</div>
</TableCell>
<TableCell>
- <Badge variant="secondary">{interview.StageType.label}</Badge>
+ <StatusBadge
+ label={interview.StageType.label}
+ color="violet"
+ className="whitespace-nowrap"
+ />
</TableCell>
- <TableCell className="hidden md:table-cell">
+ <TableCell className="hidden md:table-cell whitespace-nowrap">
<div className="flex items-center gap-1.5">
<FormatIcon className="h-3.5 w-3.5 text-muted-foreground" />
<span>{formatText(interview.format, interview.location)}</span>
@@ -124,7 +128,11 @@ function InterviewRow({
{prepSummary(interview.prepQuestions)}
</TableCell>
<TableCell>
- <Badge variant={outcomeTone(outcome)}>{outcome}</Badge>
+ <StatusBadge
+ label={outcome}
+ color={outcomeColor(outcome)}
+ className="whitespace-nowrap"
+ />
</TableCell>
<TableCell>
<DropdownMenu>
diff --git a/src/components/interviews/interviewDisplay.ts b/src/components/interviews/interviewDisplay.ts
index e0a2344..2df5ae2 100644
--- a/src/components/interviews/interviewDisplay.ts
+++ b/src/components/interviews/interviewDisplay.ts
@@ -1,5 +1,6 @@
import { format } from "date-fns";
import { STAGE_OUTCOMES } from "@/lib/constants";
+import { BadgeColor } from "@/lib/badge-colors";
// A round created through Add Stage has no outcome — the field only appears
// when editing — so a null one is derived from the date rather than left as a
@@ -15,15 +16,21 @@ export function outcomeLabel(
return occurredAt.getTime() >= now.getTime() ? "Scheduled" : "Awaiting outcome";
}
-export type OutcomeTone = "default" | "secondary" | "destructive" | "outline";
+// Keyed on the label rather than the value, because three of the labels are
+// derived (outcomeLabel) and have no stored value to key on.
+const OUTCOME_BADGE_COLORS: Record<string, BadgeColor> = {
+ Scheduled: "blue",
+ Completed: "teal",
+ Passed: "emerald",
+ Failed: "red",
+ "No-show": "red",
+ Cancelled: "slate",
+ "Awaiting outcome": "amber",
+ "Not scheduled": "slate",
+};
-export function outcomeTone(label: string): OutcomeTone {
- if (label === "Passed") return "default";
- if (label === "Failed" || label === "No-show" || label === "Cancelled") {
- return "destructive";
- }
- if (label === "Scheduled") return "outline";
- return "secondary";
+export function outcomeColor(label: string): BadgeColor {
+ return OUTCOME_BADGE_COLORS[label] ?? "slate";
}
export type FormatIcon = "video" | "phone" | "location";
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index edd223e..26763ec 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -369,6 +369,11 @@ export const SIDEBAR_LINKS = [
route: "/dashboard/myjobs",
label: "Jobs",
},
+ {
+ icon: CalendarCheck,
+ route: "/dashboard/interviews",
+ label: "Interviews",
+ },
{
icon: Zap,
route: "/dashboard/automations",
@@ -384,11 +389,6 @@ export const SIDEBAR_LINKS = [
route: "/dashboard/activities",
label: "Activities",
},
- {
- icon: CalendarCheck,
- route: "/dashboard/interviews",
- label: "Interviews",
- },
{
icon: BookOpen,
route: "/dashboard/questions",
diff --git a/wiki/getting-started.md b/wiki/getting-started.md
index 3a83e23..09d08a0 100644
--- a/wiki/getting-started.md
+++ b/wiki/getting-started.md
@@ -39,6 +39,7 @@ Five of them take you to the matching page with the form already open, so you la
- **Dashboard** — summary cards: application counts, recent jobs and activities, weekly charts, and a quick-add card for the six kinds of record you create most.
- **Jobs** — every job you are tracking, plus jobs discovered by automations.
+- **Interviews** — every interview round across your jobs in one list, with upcoming and past views, filters and outcomes.
- **Automations** — scheduled searches that pull new postings in and score them against your resume.
- **Tasks** — to-dos with a due date, priority and percent complete, and a timed activity you can start from each one.
- **Activities** — time you spend on your job hunt, timed with a start/stop timer or logged afterwards, optionally started from a task.
diff --git a/wiki/interviews.md b/wiki/interviews.md
index 74b2f38..4fe0a99 100644
--- a/wiki/interviews.md
+++ b/wiki/interviews.md
@@ -19,7 +19,7 @@ Each row shows when the round is, the job and company, which round it is, the fo
## How do I switch between upcoming and past interviews?
-Use the **Upcoming**, **Past** and **All** buttons in the page header. **Upcoming** is where the page opens: it holds every round dated from now on, plus any round you have not put a date on yet — an unscheduled round is still work ahead of you, so it sits at the top rather than out of sight. **Past** holds rounds whose date has gone, most recent first. **All** shows everything, newest first, with unscheduled rounds at the top.
+Use the **Upcoming**, **Past** and **All** buttons in the page header. **Upcoming** is where the page opens: it holds every round dated from now on, soonest first, plus any round you have not put a date on yet — an unscheduled round is still work ahead of you, so it stays in the list rather than out of sight, below the scheduled ones. **Past** holds rounds whose date has gone, most recent first. **All** shows everything, newest first, with unscheduled rounds at the end.
## How do I find one interview among many?