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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Add weekly activity chart
Khuram Niaz9df9359332e2
diff --git a/src/actions/dashboard.actions.ts b/src/actions/dashboard.actions.tsindex 9766ca1..f2cc0a4 100644--- a/src/actions/dashboard.actions.ts+++ b/src/actions/dashboard.actions.ts@@ -1,5 +1,6 @@import prisma from "@/lib/db";import { getCurrentUser } from "@/utils/user.utils";+import { format } from "date-fns";const getStartOfWeek = (date: Date) => {const currentDate = new Date(date);@@ -62,8 +63,6 @@ export const getJobsAppliedThisWeek = async (): Promise<any | undefined> => {}const startOfWeek = getStartOfWeek(new Date());const endOfWeek = getEndOfWeek(startOfWeek);- console.log("START OF WEEK: ", startOfWeek);- console.log("END OF WEEK: ", endOfWeek);try {const count = await prisma.job.count({@@ -120,3 +119,66 @@ export const getRecentJobs = async (): Promise<any | undefined> => {throw new Error(msg);}};++// Helper function to get an array of dates for the last 7 days+const getLast7Days = () => {+ const dates = [];+ for (let i = 6; i >= 0; i--) {+ const date = new Date();+ date.setDate(date.getDate() - i);+ dates.push(format(date, "PP"));+ }+ return dates;+};++export const getJobsActivityForPeriod = async (): Promise<any | undefined> => {+ try {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Not authenticated");+ }+ const today = new Date();+ const sevenDaysAgo = new Date();+ sevenDaysAgo.setDate(today.getDate() - 7);+ const jobData = await prisma.job.groupBy({+ by: "appliedDate",+ _count: {+ _all: true,+ },+ where: {+ userId: user.id,+ Status: {+ value: "applied",+ },+ appliedDate: {+ gte: sevenDaysAgo,+ lte: today,+ },+ },+ orderBy: {+ appliedDate: "asc",+ },+ });++ // Reduce to a format that groups by unique date (YYYY-MM-DD)+ const groupedPosts = jobData.reduce((acc: any, post: any) => {+ const date = format(new Date(post.appliedDate), "PP");+ acc[date] = (acc[date] || 0) + post._count._all;+ return acc;+ }, {});+ // Get the last 7 days+ const last7Days = getLast7Days();+ // Map to ensure all dates are represented with a count of 0 if necessary+ const result = last7Days.map((date) => ({+ date: date.split(",")[0],+ jobs: groupedPosts[date] || 0,+ }));++ return result;+ } catch (error) {+ const msg = "Failed to fetch jobs list. ";+ console.error(msg, error);+ throw new Error(msg);+ }+};diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsxindex 80f6c51..9fbf93f 100644--- a/src/app/dashboard/page.tsx+++ b/src/app/dashboard/page.tsx@@ -1,4 +1,5 @@import {+ getJobsActivityForPeriod,getJobsAppliedForPeriod,getRecentJobs,} from "@/actions/dashboard.actions";@@ -16,13 +17,13 @@ export const metadata: Metadata = {};export default async function Dashboard() {- const [jobsAppliedLast7Days, jobsAppliedLast30Days, recentJobs] =+ const [jobsAppliedLast7Days, jobsAppliedLast30Days, recentJobs, weeklyData] =await Promise.all([getJobsAppliedForPeriod(7),getJobsAppliedForPeriod(30),getRecentJobs(),+ getJobsActivityForPeriod(),]);- // console.log("WEEKLY COUNT: ", count);return (<><div className="grid auto-rows-max items-start gap-2 md:gap-2 lg:col-span-2">@@ -45,7 +46,7 @@ export default async function Dashboard() {<h3 className="text-2xl font-semibold leading-none tracking-tight">Weekly Activity</h3>- <WeeklyBarChart />+ <WeeklyBarChart data={weeklyData} /></div></div><div>diff --git a/src/components/JobDetails.tsx b/src/components/JobDetails.tsxindex 66a50b7..7c40fc5 100644--- a/src/components/JobDetails.tsx+++ b/src/components/JobDetails.tsx@@ -12,6 +12,8 @@ import { DialogDescription } from "@radix-ui/react-dialog";import { format } from "date-fns";import { EditorContent, useEditor } from "@tiptap/react";import StarterKit from "@tiptap/starter-kit";+import { Badge } from "./ui/badge";+import { cn } from "@/lib/utils";function JobDetails({ jobId }: { jobId: string }) {const [job, setJob] = useState<any>({});@@ -41,7 +43,24 @@ function JobDetails({ jobId }: { jobId: string }) {</DialogDescription></DialogHeader>- <h3>Applied: {format(new Date(job?.appliedDate), "PP")}</h3>+ <h3>+ {new Date() > job.dueDate && job.Status?.value === "draft" ? (+ <Badge className="bg-red-500">Expired</Badge>+ ) : (+ <Badge+ className={cn(+ "w-[70px] justify-center",+ job.Status?.value === "applied" && "bg-cyan-500",+ job.Status?.value === "interview" && "bg-green-500"+ )}+ >+ {job.Status?.label}+ </Badge>+ )}+ <span className="ml-2">+ {format(new Date(job?.appliedDate), "PP")}+ </span>+ </h3><div className="my-4"><EditorContent editor={editor} /></div>diff --git a/src/components/MyJobsTable.tsx b/src/components/MyJobsTable.tsxindex 697ea49..425133a 100644--- a/src/components/MyJobsTable.tsx+++ b/src/components/MyJobsTable.tsx@@ -120,7 +120,7 @@ function MyJobsTable() {/></TableCell><TableCell className="hidden md:table-cell">- {format(new Date(job.appliedDate), "PP")}+ {format(job.appliedDate, "PP")}</TableCell><TableCell className="font-medium">{job.JobTitle?.label}diff --git a/src/components/RecentJobsCard.tsx b/src/components/RecentJobsCard.tsxindex a87ec25..ebd5e3f 100644--- a/src/components/RecentJobsCard.tsx+++ b/src/components/RecentJobsCard.tsx@@ -3,7 +3,6 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { format } from "date-fns";export default function RecentJobsCard({ jobs }: { jobs: any[] }) {- console.log("RECENT JOBS: ", jobs[0]);return (<Card><CardHeader>diff --git a/src/components/UserAvatar.tsx b/src/components/UserAvatar.tsxindex 7b0f39a..10ed715 100644--- a/src/components/UserAvatar.tsx+++ b/src/components/UserAvatar.tsx@@ -4,7 +4,6 @@ import { CurrentUser } from "@/models/user.model";export default function UserAvatar({ user }: { user: CurrentUser | null }) {// const { data: session, status } = useSession();- // console.log("session user :", session?.user, status);if (!user) return null;return (<Imagediff --git a/src/components/WeeklyBarChart.tsx b/src/components/WeeklyBarChart.tsxindex 4ce77a0..4238963 100644--- a/src/components/WeeklyBarChart.tsx+++ b/src/components/WeeklyBarChart.tsx@@ -2,12 +2,12 @@import { barChartData } from "@/lib/data/barChartData";import { ResponsiveBar } from "@nivo/bar";-export default function WeeklyBarChart() {+export default function WeeklyBarChart({ data }: { data: any[] }) {return (<ResponsiveBar- data={barChartData.data}+ data={data}keys={["jobs"]}- indexBy="day"+ indexBy="date"margin={{top: 10,right: 10,