@@ -138,16 +138,35 @@ func Scan(ctx context.Context, opts ScanOptions) (*models.ScanResult, error) {
138138 // Run analysis
139139 analysis .AnalyzeAll (allInstances )
140140
141- // Filter out idle instances below the minimum idle days threshold
141+ // Filter out idle signals below the minimum idle days threshold
142142 if opts .MinIdleDays > 0 {
143143 minHours := float64 (opts .MinIdleDays ) * 24
144144 for i := range allInstances {
145145 inst := & allInstances [i ]
146- hasIdleOnly := len (inst .WasteSignals ) == 1 && inst .WasteSignals [0 ].Type == "idle"
147- if hasIdleOnly && inst .UptimeHours < minHours {
148- inst .WasteSignals = nil
149- inst .Recommendations = nil
150- inst .EstimatedSavings = 0
146+ if inst .UptimeHours >= minHours {
147+ continue
148+ }
149+ // Remove idle signals and their terminate recommendations
150+ var signals []models.WasteSignal
151+ for _ , s := range inst .WasteSignals {
152+ if s .Type != "idle" {
153+ signals = append (signals , s )
154+ }
155+ }
156+ var recs []models.Recommendation
157+ for _ , r := range inst .Recommendations {
158+ if r .Action != models .ActionTerminate {
159+ recs = append (recs , r )
160+ }
161+ }
162+ inst .WasteSignals = signals
163+ inst .Recommendations = recs
164+ // Recompute savings from remaining recommendations
165+ inst .EstimatedSavings = 0
166+ for _ , r := range recs {
167+ if r .MonthlySavings > inst .EstimatedSavings {
168+ inst .EstimatedSavings = r .MonthlySavings
169+ }
151170 }
152171 }
153172 }
0 commit comments