var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import AggregationInterval from "../../../Types/BaseDatabase/AggregationInterval";
import OneUptimeDate from "../../../Types/Date";
import CaptureSpan from "../../Utils/Telemetry/CaptureSpan";
export class AggregateUtil {
    static getAggregationInterval(data) {
        data.startDate = OneUptimeDate.fromString(data.startDate);
        data.endDate = OneUptimeDate.fromString(data.endDate);
        const diff = data.endDate.getTime() - data.startDate.getTime();
        if (diff <= 1000 * 60 * 60 * 3) {
            // if less than 3 hours, then get minute precision
            return AggregationInterval.Minute;
        }
        else if (diff <= 1000 * 60 * 60 * 24 * 7) {
            // 3 days
            return AggregationInterval.Hour;
        }
        else if (diff <= 1000 * 60 * 60 * 24 * 7 * 6) {
            // 3 weeks
            return AggregationInterval.Day;
        }
        else if (diff <= 1000 * 60 * 60 * 24 * 30 * 6) {
            // 3 months
            return AggregationInterval.Week;
        }
        else if (diff <= 1000 * 60 * 60 * 24 * 365 * 6) {
            // 3 years
            return AggregationInterval.Month;
        }
        return AggregationInterval.Year;
    }
}
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", String)
], AggregateUtil, "getAggregationInterval", null);
//# sourceMappingURL=AggregateBy.js.map