Skip to content

Feature/dashboard occupancy widget#238

Open
AlejandroLopez-Dev wants to merge 2 commits intooscarchapp:mainfrom
AlejandroLopez-Dev:feature/dashboard-occupancy-widget
Open

Feature/dashboard occupancy widget#238
AlejandroLopez-Dev wants to merge 2 commits intooscarchapp:mainfrom
AlejandroLopez-Dev:feature/dashboard-occupancy-widget

Conversation

@AlejandroLopez-Dev
Copy link
Copy Markdown

Adds an occupancy rate card to the dashboard. Calculated as (Bookings with state=NEW / total Rooms) * 100, rounded to the nearest integer. Handles the zero-division edge case. Covered by 6 unit test.

 - RoomsView accepts GET param 'q' and applies icontains filter
 - Template includes search form with clear button and result count
 - 12 unit tests covering edge cases (empty, whitespace, partial match,
   case-insensitivity, ordering, context preservation)
 - Calculate occupancy as (active NEW bookings / total rooms) * 100
 - Guard division by zero when no rooms exist
 - Replace hardcoded 'DEL' strings with Booking.DELETED constant
 - Move datetime imports to module level
 - Reuse bookings_today queryset to reduce redundant DB calls
 - 6 unit tests: correct calc, cancelled excluded, zero rooms, 100% full
@oscarchapp oscarchapp closed this Apr 13, 2026
@oscarchapp oscarchapp reopened this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants