RoomKitGuides
Custom Priority Configuration
Configure priority tiers and conflict resolution rules
Overview
RoomKit's priority system determines which booking wins when a conflict occurs. Each booking is assigned a priority weight based on its purposeType, and higher weights take precedence during conflict resolution.
Default Priority Tiers
RoomKit ships with four default tiers, seeded automatically when you configure priorities in the module options:
| Name | Weight | Typical Use |
|---|---|---|
LECTURE | 100 | Scheduled lectures and courses |
SEMINAR | 75 | Seminars and workshops |
STUDY_GROUP | 50 | Study groups and team meetings |
OPEN | 25 | Open bookings (fallback) |
The fallback weight is 25 — any unrecognized purposeType resolves to this value.
Configuring Custom Tiers
At Module Registration
RoomKitModule.register({
storage: adapter,
priorities: [
{ name: 'EXAM', weight: 200 },
{ name: 'LECTURE', weight: 100 },
{ name: 'SEMINAR', weight: 75 },
{ name: 'LAB', weight: 60 },
{ name: 'STUDY_GROUP', weight: 50 },
{ name: 'OFFICE_HOURS', weight: 40 },
{ name: 'OPEN', weight: 25 },
],
});At Runtime
Use the PriorityService to add or update tiers:
import { PriorityService } from '@hfu.digital/roomkit-nestjs';
@Controller('admin')
export class AdminController {
constructor(private readonly priorityService: PriorityService) {}
@Post('priorities')
async upsertTier(@Body() body: { name: string; weight: number }) {
return this.priorityService.upsert(body);
}
@Get('priorities')
async listTiers() {
return this.priorityService.getAll();
}
}How Priority Resolution Works
- When
BookingService.create()is called, it checks if an explicitprioritywas provided in the DTO - If not, it calls
PriorityService.resolve(purposeType)to look up the weight by name (case-insensitive) - If no matching tier is found, the fallback weight of
25is used - The resolved weight is stored on the booking
Conflict Resolution by Priority
When ConflictService.resolveByPriority() is called:
- The priority weights of both bookings are compared
- The booking with the higher weight wins
- If weights are equal, the existing booking wins (first-come-first-served)
- The loser is either rejected (if new) or displaced (if existing)
const resolution = conflictService.resolveByPriority(existingBooking, newBooking);
// resolution.winner: "existing" | "new"
// resolution.action: "reject_new" | "displace_existing"
// resolution.alternatives: AlternativeSuggestion[]Best Practices
- Keep weights spaced apart (multiples of 25) to leave room for new tiers
- Use meaningful names that map to your institution's booking categories
- Exam-related bookings should have the highest weight to prevent displacement
- Consider your institution's policies when deciding tie-breaking behavior