Skip to content

Commit

Permalink
boom
Browse files Browse the repository at this point in the history
  • Loading branch information
ColePurboo committed Aug 25, 2024
1 parent dd5e2cb commit 470daab
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 99 deletions.
2 changes: 2 additions & 0 deletions backend/src/graphql/resolvers/analytics.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ const analyticsResolver = {
} catch (err) {
console.error("Error executing query:", err);
throw new Error("Failed to get custom analytics");
} finally {
client.release();
}
},
},
Expand Down
63 changes: 0 additions & 63 deletions frontend/graphql/queries/analyticsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,67 +346,4 @@ export const GET_ANALYTICS_DASHBOARD_DATA = gql`
count
}
}
`;

export const GET_DASHBOARD_JOB_CLICKS = gql`
query GetDashboardJobClicks($startDate: Date!, $endDate: Date!) {
daily: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "daily", clickType: "job") {
date
count
}
weekly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "weekly", clickType: "job") {
date
count
}
jobClicksMonthly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "monthly", clickType: "job") {
date
count
}
jobClicksYearly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "yearly", clickType: "job") {
date
count
}
}
`;

export const GET_DASHBOARD_APPLY_CLICKS = gql`
query GetDashboardApplyClicks($startDate: Date!, $endDate: Date!) {
daily: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "daily", clickType: "apply") {
date
count
}
weekly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "weekly", clickType: "apply") {
date
count
}
monthly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "monthly", clickType: "apply") {
date
count
}
yearly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "yearly", clickType: "apply") {
date
count
}
}
`;

export const GET_DASHBOARD_EMPLOYER_CLICKS = gql`
query GetDashboardEmployerClicks($startDate: Date!, $endDate: Date!) {
daily: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "daily", clickType: "employer") {
date
count
}
weekly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "weekly", clickType: "employer") {
date
count
}
monthly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "monthly", clickType: "employer") {
date
count
}
yearly: getClicksCustomAnalytics(startDate: $startDate, endDate: $endDate, interval: "yearly", clickType: "employer") {
date
count
}
}
`;
65 changes: 29 additions & 36 deletions frontend/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
import { useQuery } from '@apollo/client'
import { useQuery } from "@apollo/client";
import {
GET_DASHBOARD_APPLY_CLICKS,
GET_DASHBOARD_EMPLOYER_CLICKS,
GET_DASHBOARD_JOB_CLICKS,
} from '../graphql/queries/analyticsQueries'
import { Chart } from 'react-google-charts'
import styles from '../styles/Dashboard.module.css'
import Navbar from '../src/components/general/Navbar'
GET_ANALYTICS_DASHBOARD_DATA
} from "../graphql/queries/analyticsQueries";
import { Chart } from "react-google-charts";
import styles from "../styles/Dashboard.module.css";
import Navbar from "../src/components/general/Navbar";

function Dashboard() {
const {
data: jobClicks,
loading: jobClicksLoading,
error: jobClicksError,
} = useQuery(GET_DASHBOARD_JOB_CLICKS, {
variables: { startDate: '2024-01-01', endDate: '2024-08-01' },
})
const {
data: applyClicks,
loading: applyClicksLoading,
error: applyClicksError,
} = useQuery(GET_DASHBOARD_APPLY_CLICKS, {
variables: { startDate: '2024-01-01', endDate: '2024-08-01' },
})
const {
data: employerClicks,
loading: employerClicksLoading,
error: employerClicksError,
} = useQuery(GET_DASHBOARD_EMPLOYER_CLICKS, {
variables: { startDate: '2024-01-01', endDate: '2024-08-01' },
})
const { data, loading, error } = useQuery(GET_ANALYTICS_DASHBOARD_DATA, {
variables: { startDate: "2024-01-01", endDate: "2024-08-01" },
});

if (jobClicksLoading || applyClicksLoading || employerClicksLoading) return <div>loading</div>
if (loading) return <div>loading</div>;
if (error) return <div>error</div>;

const dailyClickCounts = [['Date', 'Daily Count'], ...jobClicks.daily.map((item: any) => [item.date, item.count])]

const dailyClickCounts = [
["Date", "Daily Count"],
...data.jobClicksDaily.map((item: any) => [item.date, item.count]),
...data.applyClicksDaily.map((item: any) => [item.date, item.count]),
...data.employerClicksDaily.map((item: any) => [item.date, item.count])
];
const dailyChartOptions = {
title: 'Daily Clicks',
}
title: "Daily Clicks",
};

return (
<>
<Navbar />
<main>
<Chart chartType='Line' width='80%' height='400px' data={dailyClickCounts} options={dailyChartOptions} />
<Chart
chartType="Line"
width="80%"
height="400px"
data={dailyClickCounts}
options={dailyChartOptions}
/>
</main>
</>
)
);
}

export default Dashboard
export default Dashboard;

0 comments on commit 470daab

Please sign in to comment.