Skip to content

Commit

Permalink
feat(dashboard): show building next to state
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Dec 17, 2024
1 parent 9868705 commit 84a0c03
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib/server/db/employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function getEmployees(
fname: string;
lname: string;
department: string;
building: string | null;
state: State;
}[]
> {
Expand All @@ -43,6 +44,7 @@ export async function getEmployees(
lname: employee.lname,
department: employee.department,
entryTimestamp: sql<Date>`MAX(${employeeEntry.timestamp})`.as('entryTimestamp'),
entryBuilding: employeeEntry.building,
exitTimestamp: sql<Date | null>`MAX(${employeeExit.timestamp})`.as('exitTimestamp')
})
.from(employee)
Expand All @@ -61,7 +63,7 @@ export async function getEmployees(
: [])
)
)
.groupBy(employee.id, employee.fname, employee.lname)
.groupBy(employee.id, employee.email, employee.fname, employee.lname, employeeEntry.building)
.limit(limit)
.offset(offset);

Expand All @@ -72,6 +74,7 @@ export async function getEmployees(
fname: s.fname,
lname: s.lname,
department: s.department,
building: isInside(s.entryTimestamp, s.exitTimestamp) ? s.entryBuilding : null,
state: isInside(s.entryTimestamp, s.exitTimestamp) ? StateInside : StateOutside
};
});
Expand Down
5 changes: 4 additions & 1 deletion src/lib/server/db/student.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function getStudents(
fname: string;
lname: string;
department: string;
building: string | null;
state: State;
}[]
> {
Expand All @@ -43,6 +44,7 @@ export async function getStudents(
lname: student.lname,
department: student.department,
entryTimestamp: sql<Date>`MAX(${studentEntry.timestamp})`.as('entryTimestamp'),
entryBuilding: studentEntry.building,
exitTimestamp: sql<Date | null>`MAX(${studentExit.timestamp})`.as('exitTimestamp')
})
.from(student)
Expand All @@ -61,7 +63,7 @@ export async function getStudents(
: [])
)
)
.groupBy(student.id, student.index, student.fname, student.lname)
.groupBy(student.id, student.index, student.fname, student.lname, studentEntry.building)
.limit(limit)
.offset(offset);

Expand All @@ -72,6 +74,7 @@ export async function getStudents(
fname: s.fname,
lname: s.lname,
department: s.department,
building: isInside(s.entryTimestamp, s.exitTimestamp) ? s.entryBuilding : null,
state: isInside(s.entryTimestamp, s.exitTimestamp) ? StateInside : StateOutside
};
});
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export type Person = {
fname: string;
lname: string;
department: string;
building: string | null;
state: State;
};
2 changes: 2 additions & 0 deletions src/routes/(dashboard)/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const load: PageServerLoad = async ({ url }) => {
fname: s.fname,
lname: s.lname,
department: s.department,
building: s.building,
state: s.state
})),
...employees.map((e) => ({
Expand All @@ -31,6 +32,7 @@ export const load: PageServerLoad = async ({ url }) => {
fname: e.fname,
lname: e.lname,
department: e.department,
building: e.building,
state: e.state
}))
];
Expand Down
4 changes: 4 additions & 0 deletions src/routes/(dashboard)/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const columns: ColumnDef<Person>[] = [
accessorKey: 'department',
header: 'Department'
},
{
accessorKey: 'building',
header: 'Building'
},
{
accessorKey: 'state',
header: 'State'
Expand Down

0 comments on commit 84a0c03

Please sign in to comment.