"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureLifecycleReadModel = void 0;
const get_current_stage_1 = require("./get-current-stage");
class FeatureLifecycleReadModel {
    constructor(db) {
        this.db = db;
    }
    async findCurrentStage(feature) {
        const results = await this.db('feature_lifecycles')
            .where({ feature })
            .orderBy('created_at', 'asc');
        const stages = results.map(({ stage, created_at }) => ({
            stage,
            enteredStageAt: created_at,
        }));
        return (0, get_current_stage_1.getCurrentStage)(stages);
    }
}
exports.FeatureLifecycleReadModel = FeatureLifecycleReadModel;
//# sourceMappingURL=feature-lifecycle-read-model.js.map