Add UI console and spare forecast naming
This commit is contained in:
@@ -36,7 +36,7 @@ type FirmwareRisk struct {
|
||||
FailureRate *float64
|
||||
}
|
||||
|
||||
type ZipForecast struct {
|
||||
type SpareForecast struct {
|
||||
LotID *int64
|
||||
LotCode *string
|
||||
ComponentCount int64
|
||||
@@ -154,21 +154,21 @@ func (r *Repository) ListFirmwareRisk(ctx context.Context, start, end time.Time)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func (r *Repository) ForecastZIP(ctx context.Context, start, end time.Time, horizonDays int, multiplier float64) ([]ZipForecast, error) {
|
||||
func (r *Repository) ForecastSpare(ctx context.Context, start, end time.Time, horizonDays int, multiplier float64) ([]SpareForecast, error) {
|
||||
metrics, err := r.ListLotMetrics(ctx, start, end)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
horizonYears := float64(horizonDays) / 365
|
||||
items := make([]ZipForecast, 0, len(metrics))
|
||||
items := make([]SpareForecast, 0, len(metrics))
|
||||
for _, metric := range metrics {
|
||||
expected := metric.AFR * float64(metric.ComponentCount) * horizonYears
|
||||
if expected < 0 {
|
||||
expected = 0
|
||||
}
|
||||
spares := int64(math.Ceil(expected * multiplier))
|
||||
items = append(items, ZipForecast{
|
||||
items = append(items, SpareForecast{
|
||||
LotID: metric.LotID,
|
||||
LotCode: metric.LotCode,
|
||||
ComponentCount: metric.ComponentCount,
|
||||
|
||||
Reference in New Issue
Block a user