summaryrefslogtreecommitdiff
path: root/pkg/domain/entities/reports/prune.go
blob: 5494ac3ae5f48547cf1c334545b909ec143284ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package reports

type PruneReport struct {
	Id   string //nolint
	Err  error
	Size uint64
}

func PruneReportsIds(r []*PruneReport) []string {
	ids := make([]string, 0, len(r))
	for _, v := range r {
		if v == nil || v.Id == "" {
			continue
		}
		ids = append(ids, v.Id)
	}
	return ids
}

func PruneReportsErrs(r []*PruneReport) []error {
	errs := make([]error, 0, len(r))
	for _, v := range r {
		if v == nil || v.Err == nil {
			continue
		}
		errs = append(errs, v.Err)
	}
	return errs
}

func PruneReportsSize(r []*PruneReport) uint64 {
	size := uint64(0)
	for _, v := range r {
		if v == nil {
			continue
		}
		size = size + v.Size
	}
	return size
}