Skip to content

[BE-34] Occupancy forecasting: backend #1215

Description

@yusuftomilola

Overview

Admins manage workspace capacity reactively. Forecasting predicts future demand based on historical booking patterns — enabling proactive pricing adjustments, staffing decisions, and workspace promotion.

Context

  • Booking entity: backend/src/bookings/entities/booking.entity.tsstartDate, workspaceId, planType, status
  • Workspace entity: backend/src/workspaces/entities/workspace.entity.tstotalSeats
  • DashboardModule: backend/src/dashboard/ — add forecast endpoint here

Tasks

  • GET /dashboard/admin/occupancy-forecast — returns predicted occupancy per workspace for the next 30 days
  • Algorithm for each future date D and workspace W:
    • Find all CONFIRMED or COMPLETED bookings for W on the same day-of-week as D over the past 90 days
    • Compute average occupied seats on those historical days
    • Divide by W.totalSeats to get predictedOccupancyPercent (0–100)
  • Response: { predictions: [{ date, workspaceId, workspaceName, predictedOccupancyPercent }] }
  • Supports ?workspaceId= filter to return forecast for a single workspace
  • Endpoint is admin only

Files to Modify / Create

  • backend/src/dashboard/dashboard.controller.ts
  • backend/src/dashboard/providers/admin-analytics.provider.ts

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions