MCPcopy Create free account
hub / github.com/coder/coder / getOldestPrebuildIDs

Method getOldestPrebuildIDs

coderd/prebuilds/preset_snapshot.go:472–486  ·  view source on GitHub ↗

getOldestPrebuildIDs returns the IDs of the N oldest prebuilds, sorted by creation time. This is used when we need to delete prebuilds, ensuring we remove the oldest ones first.

(n int)

Source from the content-addressed store, hash-verified

470// getOldestPrebuildIDs returns the IDs of the N oldest prebuilds, sorted by creation time.
471// This is used when we need to delete prebuilds, ensuring we remove the oldest ones first.
472func (p PresetSnapshot) getOldestPrebuildIDs(n int) []uuid.UUID {
473 // Sort by creation time, oldest first
474 slices.SortFunc(p.Running, func(a, b database.GetRunningPrebuiltWorkspacesRow) int {
475 return a.CreatedAt.Compare(b.CreatedAt)
476 })
477
478 // Take the first N IDs
479 n = min(n, len(p.Running))
480 ids := make([]uuid.UUID, n)
481 for i := 0; i < n; i++ {
482 ids[i] = p.Running[i].ID
483 }
484
485 return ids
486}

Calls 1

CompareMethod · 0.80

Tested by

no test coverage detected