• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

brotherlogic / cdprocessor / 20643236445

01 Jan 2026 06:14PM UTC coverage: 54.22%. First build
20643236445

Pull #6506

github

brotherlogic
Add tracking for togo rips
Pull Request #6506: Add tracking for togo rips

0 of 2 new or added lines in 1 file covered. (0.0%)

379 of 699 relevant lines covered (54.22%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.29
/cdprocessorapi.go
1
package main
2

3
import (
4
        "fmt"
5
        "sort"
6
        "time"
7

8
        "golang.org/x/net/context"
9

10
        pb "github.com/brotherlogic/cdprocessor/proto"
11
        pbcdp "github.com/brotherlogic/cdprocessor/proto"
12
        rcpb "github.com/brotherlogic/recordcollection/proto"
13
        "github.com/prometheus/client_golang/prometheus"
14
        "github.com/prometheus/client_golang/prometheus/promauto"
15
)
16

17
var (
18
        togo = promauto.NewGauge(prometheus.GaugeOpts{
19
                Name: "cdprocessor_togo",
20
                Help: "The number of records needing a rip",
21
        })
22
)
23

24
func (s *Server) updateMetrics(ctx context.Context, config *pb.Config) {
×
25
        last24 := 0
×
26
        s.CtxLog(ctx, fmt.Sprintf("SEEN METRICS %v", len(config.GetGoalFolder())))
×
27
        for key, date := range config.GetLastRipTime() {
×
28
                s.CtxLog(ctx, fmt.Sprintf("SEEN %v -> %v", key, config.GetGoalFolder()[key]))
×
29
                if val, ok := config.GetGoalFolder()[key]; ok && val != 1782105 {
×
30
                        if time.Since(time.Unix(date, 0)) < time.Hour*18 {
×
31
                                last24++
×
32
                        }
×
33
                }
34
        }
35

36
        ripped24Hours.Set(float64(last24))
×
NEW
37

×
NEW
38
        togo.Set(float64(len(config.GetToGo())))
×
39
}
40

41
// GetRipped returns the ripped cds
42
func (s *Server) GetRipped(ctx context.Context, req *pbcdp.GetRippedRequest) (*pbcdp.GetRippedResponse, error) {
1✔
43
        return &pbcdp.GetRippedResponse{Ripped: s.rips}, nil
1✔
44
}
1✔
45

46
// GetMissing gets the missing rips
47
func (s *Server) GetMissing(ctx context.Context, req *pbcdp.GetMissingRequest) (*pbcdp.GetMissingResponse, error) {
1✔
48
        config, err := s.load(ctx)
1✔
49
        if err != nil {
2✔
50
                return nil, err
1✔
51
        }
1✔
52

53
        sort.Slice(config.ToGo, func(i, j int) bool {
×
54
                return config.ToGo[i] < config.ToGo[j]
×
55
        })
×
56

57
        var record *rcpb.Record
×
58
        if len(config.ToGo) > 0 {
×
59
                record, err = s.getter.getRecord(ctx, config.ToGo[0])
×
60
                if err != nil {
×
61
                        return nil, err
×
62
                }
×
63
        }
64

65
        return &pbcdp.GetMissingResponse{Missing: []*rcpb.Record{record}}, nil
×
66
}
67

68
// Force the processor to do something
69
func (s *Server) Force(ctx context.Context, req *pbcdp.ForceRequest) (*pbcdp.ForceResponse, error) {
1✔
70
        config, err := s.load(ctx)
1✔
71
        if err != nil {
2✔
72
                return nil, err
1✔
73
        }
1✔
74
        s.hack.Lock()
×
75
        defer s.hack.Unlock()
×
76
        switch req.Type {
×
77
        case pbcdp.ForceRequest_RECREATE_LINKS:
×
78
                return &pbcdp.ForceResponse{}, s.makeLinks(ctx, req.Id, true, config)
×
79
        }
80
        return nil, fmt.Errorf("Unknow force request")
×
81
}
82

83
// ClientUpdate on an updated record
84
func (s *Server) ClientUpdate(ctx context.Context, req *rcpb.ClientUpdateRequest) (*rcpb.ClientUpdateResponse, error) {
×
85
        //return &rcpb.ClientUpdateResponse{}, nil
×
86
        config, err := s.load(ctx)
×
87
        if err != nil {
×
88
                return nil, err
×
89
        }
×
90
        s.hack.Lock()
×
91
        defer s.hack.Unlock()
×
92

×
93
        err = s.makeLinks(ctx, req.GetInstanceId(), false, config)
×
94
        if err == nil {
×
95
                var ntogo []int32
×
96
                for _, togo := range config.ToGo {
×
97
                        if togo != req.GetInstanceId() {
×
98
                                ntogo = append(ntogo, togo)
×
99
                        }
×
100
                }
101
                config.ToGo = ntogo
×
102
                err = s.save(ctx, config)
×
103
                if err != nil {
×
104
                        return nil, err
×
105
                }
×
106
        } else {
×
107
                found := false
×
108
                for _, togo := range config.ToGo {
×
109
                        if togo == req.GetInstanceId() {
×
110
                                found = true
×
111
                        }
×
112
                }
113
                if !found {
×
114
                        config.ToGo = append(config.ToGo, req.GetInstanceId())
×
115
                        serr := s.save(ctx, config)
×
116
                        if serr != nil {
×
117
                                return nil, serr
×
118
                        }
×
119
                }
120
        }
121

122
        return &rcpb.ClientUpdateResponse{}, err
×
123
}
124

125
func (s *Server) GetOutstanding(ctx context.Context, req *pbcdp.GetOutstandingRequest) (*pbcdp.GetOutstandingResponse, error) {
×
126
        config, err := s.load(ctx)
×
127
        if err != nil {
×
128
                return nil, err
×
129
        }
×
130

131
        var nums []int32
×
132
        for _, issue := range config.GetIssueMapping() {
×
133
                nums = append(nums, issue)
×
134
        }
×
135

136
        return &pbcdp.GetOutstandingResponse{Ids: nums}, nil
×
137
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc