package org.raddatz.familienarchiv.document;

import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDate;
import java.util.List;

/**
 * Result of the timeline density aggregation.
 *
 * <p>{@code minDate} / {@code maxDate} are intentionally not marked
 * {@code @Schema(requiredMode = REQUIRED)} — the empty-result case (no
 * documents match the filter) returns them as {@code null}, which surfaces in
 * the generated TypeScript as {@code minDate?: string | null}. Frontend code
 * must treat them as optional.
 */
public record DocumentDensityResult(
        @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
        List<MonthBucket> buckets,
        LocalDate minDate,
        LocalDate maxDate
) {
    /** The "no documents match the filter" result, with no buckets and null date bounds. */
    public static DocumentDensityResult empty() {
        return new DocumentDensityResult(List.of(), null, null);
    }
}
