Skip to content

Commit

Permalink
Added more general/static counts to dashboard
Browse files Browse the repository at this point in the history
Also fixed small code stinks
  • Loading branch information
rayceramsay committed Sep 2, 2024
1 parent a418987 commit cdc656b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
16 changes: 16 additions & 0 deletions frontend/graphql/queries/analyticsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,25 @@ export const GET_ANALYTICS_DASHBOARD_DATA = gql`
tag
job_count
}
jobLocationRankings: getJobLocationRanking {
location
job_count
}
jobDeadlineRankingsByMonth: getJobDeadlineRankingByMonth {
month
job_count
}
daysSinceLastJobPostByEmployer: getNumDaysSinceLastJobPostByEmployer {
employerName
days_since_last_post
}
scholarsRankedByMajor: getScholarsRankedByMajor {
major
scholar_count
}
scholarsRankedByYear: getScholarsRankedByYear {
year
scholar_count
}
}
`
58 changes: 51 additions & 7 deletions frontend/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DashboardTwoItemTable from '../src/components/admin/DashboardTwoItemTable
import Spinner from '../src/components/admin/Spinner'
import FancySpinner from '../src/components/admin/FancySpinner'

function Dashboard() {
export default function Dashboard() {
const currentDateObj = new Date()
const currentDate = currentDateObj.toISOString().split('T')[0]
const currentYear = currentDateObj.getFullYear()
Expand Down Expand Up @@ -39,11 +39,33 @@ function Dashboard() {
)
const currentPageData = pageData ? pageData : previousPageData
if (currentPageData) {
const jobTagRankings: [{ tag: string; job_count: string }] = currentPageData['jobTagRankings']
const jobTagRankingsTableBodyData = jobTagRankings.map((ranking) => [ranking.tag, ranking.job_count])

const jobLocationRankings: [{ location: string; job_count: string }] = currentPageData['jobLocationRankings']
const jobLocationRankingsTableBodyData = jobLocationRankings.map((ranking) => [ranking.location, ranking.job_count])

const jobDeadlineRankingsByMonth: [{ month: string; job_count: string }] =
currentPageData['jobDeadlineRankingsByMonth']
const jobDeadlineRankingsByMonthTableBodyData = jobDeadlineRankingsByMonth.map((ranking) => [
ranking.month,
ranking.job_count,
])

const daysSinceLastJobPostByEmployer: [{ employerName: string; days_since_last_post: string }] =
currentPageData['daysSinceLastJobPostByEmployer']
const daysSinceLastJobPostByEmployerTableBodyData = daysSinceLastJobPostByEmployer.map((ranking) => [
ranking.employerName,
ranking.days_since_last_post,
])

daysSinceLastJobPostByEmployer

const scholarsByMajor: [{ major: string; scholar_count: string }] = currentPageData['scholarsRankedByMajor']
const scholarsByMajorTableBodyData = scholarsByMajor.map((ranking) => [ranking.major, ranking.scholar_count])

const jobTagRankings: [{ tag: string; job_count: string }] = currentPageData['jobTagRankings']
const jobTagRankingsTableBodyData = jobTagRankings.map((ranking) => [ranking.tag, ranking.job_count])
const scholarsByYear: [{ year: string; scholar_count: string }] = currentPageData['scholarsRankedByYear']
const scholarsByYearTableBodyData = scholarsByYear.map((ranking) => [ranking.year, ranking.scholar_count])

const jobTagsByClicks: [{ tag: string; click_count: string }] = currentPageData['jobTagRankingsByClicks']
const jobTagsByClicksTableBodyData = jobTagsByClicks.map((ranking) => [ranking.tag, ranking.click_count])
Expand Down Expand Up @@ -78,11 +100,35 @@ function Dashboard() {
DashboardContent = (
<>
<div className={styles.titleRow}>
<h2 className={styles.mainTitle}>Scholar and Job Counts</h2>
<h2 className={styles.mainTitle}>General Counts</h2>
</div>
<div className={styles.quickStats}>
<DashboardTwoItemTable firstHeading='MAJOR' secondHeading='SCHOLARS' data={scholarsByMajorTableBodyData} />
<DashboardTwoItemTable firstHeading='JOB TAG' secondHeading='JOBS' data={jobTagRankingsTableBodyData} />
<DashboardTwoItemTable
firstHeading='JOB LOCATION'
secondHeading='JOBS'
data={jobLocationRankingsTableBodyData}
/>
<DashboardTwoItemTable
firstHeading='JOB DEADLINE (MONTH)'
secondHeading='JOBS'
data={jobDeadlineRankingsByMonthTableBodyData}
/>
<DashboardTwoItemTable
firstHeading='EMPLOYER NAME'
secondHeading='DAYS SINCE LAST JOB POST'
data={daysSinceLastJobPostByEmployerTableBodyData}
/>
<DashboardTwoItemTable
firstHeading='SCHOLAR MAJOR'
secondHeading='SCHOLARS'
data={scholarsByMajorTableBodyData}
/>
<DashboardTwoItemTable
firstHeading='SCHOLAR YEAR'
secondHeading='SCHOLARS'
data={scholarsByYearTableBodyData}
/>
</div>
<div className={styles.titleRow}>
<h2 className={styles.mainTitle}>
Expand Down Expand Up @@ -152,5 +198,3 @@ function Dashboard() {
</>
)
}

export default Dashboard
1 change: 0 additions & 1 deletion frontend/src/components/admin/FancySpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import styles from '../../../styles/components/FancySpinner.module.css'

type SpinnerProps = {
size?: number
thickness?: number
}

export default function FancySpinner({ size = 100 }: SpinnerProps) {
Expand Down

0 comments on commit cdc656b

Please sign in to comment.