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

brotherlogic / cdprocessor / 21414262886

27 Jan 2026 09:08PM UTC coverage: 53.912%. First build
21414262886

Pull #6552

github

brotherlogic
Fixes deleted record
Pull Request #6552: Fixes deleted record

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

379 of 703 relevant lines covered (53.91%)

0.67 hits per line

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

14.61
/cdprocessorapi.go
1
package main
2

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

8
        "golang.org/x/net/context"
9
        "google.golang.org/grpc/codes"
10
        "google.golang.org/grpc/status"
11

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

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

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

38
        ripped24Hours.Set(float64(last24))
×
39

×
40
        togo.Set(float64(len(config.GetToGo())))
×
41
}
42

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

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

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

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

×
NEW
64
                        if status.Code(err) == codes.OutOfRange {
×
NEW
65
                                config.ToGo = config.ToGo[1:]
×
NEW
66
                                return &pbcdp.GetMissingResponse{Missing: []*rcpb.Record{}}, s.save(ctx, config)
×
NEW
67
                        }
×
68

69
                        return nil, err
×
70
                }
71
        }
72

73
        return &pbcdp.GetMissingResponse{Missing: []*rcpb.Record{record}}, nil
×
74
}
75

76
// Force the processor to do something
77
func (s *Server) Force(ctx context.Context, req *pbcdp.ForceRequest) (*pbcdp.ForceResponse, error) {
1✔
78
        config, err := s.load(ctx)
1✔
79
        if err != nil {
2✔
80
                return nil, err
1✔
81
        }
1✔
82
        s.hack.Lock()
×
83
        defer s.hack.Unlock()
×
84
        switch req.Type {
×
85
        case pbcdp.ForceRequest_RECREATE_LINKS:
×
86
                return &pbcdp.ForceResponse{}, s.makeLinks(ctx, req.Id, true, config)
×
87
        }
88
        return nil, fmt.Errorf("Unknow force request")
×
89
}
90

91
// ClientUpdate on an updated record
92
func (s *Server) ClientUpdate(ctx context.Context, req *rcpb.ClientUpdateRequest) (*rcpb.ClientUpdateResponse, error) {
×
93
        //return &rcpb.ClientUpdateResponse{}, nil
×
94
        config, err := s.load(ctx)
×
95
        if err != nil {
×
96
                return nil, err
×
97
        }
×
98
        s.hack.Lock()
×
99
        defer s.hack.Unlock()
×
100

×
101
        err = s.makeLinks(ctx, req.GetInstanceId(), false, config)
×
102
        if err == nil {
×
103
                var ntogo []int32
×
104
                for _, togo := range config.ToGo {
×
105
                        if togo != req.GetInstanceId() {
×
106
                                ntogo = append(ntogo, togo)
×
107
                        }
×
108
                }
109
                config.ToGo = ntogo
×
110
                err = s.save(ctx, config)
×
111
                if err != nil {
×
112
                        return nil, err
×
113
                }
×
114
        } else {
×
115
                found := false
×
116
                for _, togo := range config.ToGo {
×
117
                        if togo == req.GetInstanceId() {
×
118
                                found = true
×
119
                        }
×
120
                }
121
                if !found {
×
122
                        config.ToGo = append(config.ToGo, req.GetInstanceId())
×
123
                        serr := s.save(ctx, config)
×
124
                        if serr != nil {
×
125
                                return nil, serr
×
126
                        }
×
127
                }
128
        }
129

130
        return &rcpb.ClientUpdateResponse{}, err
×
131
}
132

133
func (s *Server) GetOutstanding(ctx context.Context, req *pbcdp.GetOutstandingRequest) (*pbcdp.GetOutstandingResponse, error) {
×
134
        config, err := s.load(ctx)
×
135
        if err != nil {
×
136
                return nil, err
×
137
        }
×
138

139
        var nums []int32
×
140
        for _, issue := range config.GetIssueMapping() {
×
141
                nums = append(nums, issue)
×
142
        }
×
143

144
        return &pbcdp.GetOutstandingResponse{Ids: nums}, nil
×
145
}
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