package com.arms.api.report.rolling3m.model.vo;

import lombok.*;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class IssueArmsStateCountVO {

    private long total;
    private long open;
    private long inProgress;
    private long completed;
    private double completionRate;

    public static IssueArmsStateCountVO from(long total, long open, long inProgress, long completed) {
        double completionRate = total == 0 ? 0.0 : Math.round(completed * 100.0 / total * 10.0) / 10.0;
        return IssueArmsStateCountVO.builder()
                .total(total).open(open).inProgress(inProgress).completed(completed)
                .completionRate(completionRate)
                .build();
    }
}
