11// Copyright (c) 2026 Falko Schumann. All rights reserved. MIT license.
22
3- import { Temporal } from "@js-temporal/polyfill" ;
4-
53import { Clock , isTimestampInPeriod } from "../../shared/domain/temporal" ;
64import type {
75 TimesheetQuery ,
@@ -14,55 +12,58 @@ import { VacationChangedEvent } from "../domain/vacation_changed_event";
1412import type { EventStore } from "../infrastructure/event_store" ;
1513import { HolidayRepository } from "../infrastructure/holiday_repository" ;
1614import { VacationRepository } from "../infrastructure/vacation_repository" ;
15+ import type { SettingsProvider } from "../infrastructure/settings_provider" ;
1716
1817export class TimesheetQueryHandler {
1918 static create ( {
20- capacity = "PT30M" ,
2119 eventStore,
2220 holidayRepository,
2321 vacationRepository,
22+ settingsProvider,
2423 clock = Clock . systemDefaultZone ( ) ,
2524 } : {
26- capacity ?: Temporal . DurationLike | string ;
2725 eventStore : EventStore ;
2826 holidayRepository : HolidayRepository ;
2927 vacationRepository : VacationRepository ;
28+ settingsProvider : SettingsProvider ;
3029 clock ?: Clock ;
3130 } ) {
3231 return new TimesheetQueryHandler (
33- capacity ,
3432 eventStore ,
3533 holidayRepository ,
3634 vacationRepository ,
35+ settingsProvider ,
3736 clock ,
3837 ) ;
3938 }
4039
41- capacity : Temporal . Duration ;
42-
43- readonly #eventStore: EventStore ;
44- readonly #holidayRepository: HolidayRepository ;
45- readonly #vacationRepository: VacationRepository ;
46- readonly #clock: Clock ;
40+ readonly #eventStore;
41+ readonly #holidayRepository;
42+ readonly #vacationRepository;
43+ readonly #settingsProvider;
44+ readonly #clock;
4745
4846 private constructor (
49- capacity : Temporal . DurationLike | string ,
5047 eventStore : EventStore ,
5148 holidayRepository : HolidayRepository ,
5249 vacationRepository : VacationRepository ,
50+ settingsProvider : SettingsProvider ,
5351 clock : Clock ,
5452 ) {
55- this . capacity = Temporal . Duration . from ( capacity ) ;
5653 this . #eventStore = eventStore ;
5754 this . #holidayRepository = holidayRepository ;
5855 this . #vacationRepository = vacationRepository ;
56+ this . #settingsProvider = settingsProvider ;
5957 this . #clock = clock ;
6058 }
6159
6260 async handle ( query : TimesheetQuery ) : Promise < TimesheetQueryResult > {
6361 const readModel = new TimesheetReadModel ( ) ;
6462
65- readModel . project ( CapacityChangedEvent . create ( { capacity : this . capacity } ) ) ;
63+ const settings = await this . #settingsProvider. load ( ) ;
64+ readModel . project (
65+ CapacityChangedEvent . create ( { capacity : settings . capacity } ) ,
66+ ) ;
6667
6768 const holidays = await this . #holidayRepository. findAllByDate (
6869 query . from ,
0 commit comments