Skip to content

Commit

Permalink
Fix office occupancy stats queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ba1uev committed May 29, 2024
1 parent d7dd678 commit 206d9dd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
7 changes: 1 addition & 6 deletions config-demo/company.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@
"visitsConfig": {
"workingDays": [0, 1, 2, 3, 4],
"bookableDays": 30,
"maxCapacity": 35,
"capacityThresholds": {
"low": 5,
"medium": 14,
"high": 27
}
"maxCapacity": 35
},
"areas": [
{
Expand Down
5 changes: 0 additions & 5 deletions docs/create-new-office.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ Open the `app.config.json` file and scroll down to the `offices` section. This s
"workingDays": [0, 1, 2, 3, 4], // Mon-Fri
"bookableDays": 30, // how many days in advance are allowed to book
"maxCapacity": 35, // maximum office capacity (including non-working desks)
"capacityThresholds": { // only for stats
"low": 5,
"medium": 20,
"high": 30
}
},
"areas": [
{
Expand Down
2 changes: 2 additions & 0 deletions src/modules/visits/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ const adminRouter: FastifyPluginCallback = async (fastify, opts) => {

result.visitsTotal = await fastify.db.Visit.count({
where: {
officeId: office.id,
date: {
[Op.gte]: startDate,
[Op.lte]: endDate,
Expand All @@ -741,6 +742,7 @@ const adminRouter: FastifyPluginCallback = async (fastify, opts) => {
})
result.visitsToday = await fastify.db.Visit.count({
where: {
officeId: office.id,
date: {
[Op.gte]: dayjs().startOf('day').toDate(),
[Op.lte]: dayjs().endOf('day').toDate(),
Expand Down
5 changes: 0 additions & 5 deletions src/server/app-config/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export const officeVisitsConfig = z.object({
workingDays: z.array(z.number().min(0).max(6)).min(1).max(7),
bookableDays: z.number().min(1),
maxCapacity: z.number().min(1),
capacityThresholds: z.object({
low: z.number().min(1),
medium: z.number().min(1),
high: z.number().min(1),
}),
})

export const officeAreaDesk = z
Expand Down

0 comments on commit 206d9dd

Please sign in to comment.