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

brotherlogic / cdprocessor / 18606773929

17 Oct 2025 11:00PM UTC coverage: 53.659%. First build
18606773929

Pull #6345

github

brotherlogic
Better tracking of missing
Pull Request #6345: Raise bug on missing tracks

6 of 43 new or added lines in 2 files covered. (13.95%)

374 of 697 relevant lines covered (53.66%)

0.66 hits per line

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

15.66
/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
)
14

15
func (s *Server) updateMetrics(ctx context.Context, config *pb.Config) {
×
16
        last24 := 0
×
17
        s.CtxLog(ctx, fmt.Sprintf("SEEN METRICS %v", len(config.GetGoalFolder())))
×
18
        for key, date := range config.GetLastRipTime() {
×
19
                s.CtxLog(ctx, fmt.Sprintf("SEEN %v -> %v", key, config.GetGoalFolder()[key]))
×
20
                if val, ok := config.GetGoalFolder()[key]; ok && val != 1782105 {
×
21
                        if time.Since(time.Unix(date, 0)) < time.Hour*18 {
×
22
                                last24++
×
23
                        }
×
24
                }
25
        }
26

27
        ripped24Hours.Set(float64(last24))
×
28
}
29

30
// GetRipped returns the ripped cds
31
func (s *Server) GetRipped(ctx context.Context, req *pbcdp.GetRippedRequest) (*pbcdp.GetRippedResponse, error) {
1✔
32
        return &pbcdp.GetRippedResponse{Ripped: s.rips}, nil
1✔
33
}
1✔
34

35
// GetMissing gets the missing rips
36
func (s *Server) GetMissing(ctx context.Context, req *pbcdp.GetMissingRequest) (*pbcdp.GetMissingResponse, error) {
1✔
37
        config, err := s.load(ctx)
1✔
38
        if err != nil {
2✔
39
                return nil, err
1✔
40
        }
1✔
41

NEW
42
        sort.Slice(config.ToGo, func(i, j int) bool {
×
NEW
43
                return config.ToGo[i] < config.ToGo[j]
×
NEW
44
        })
×
45

NEW
46
        var record *rcpb.Record
×
NEW
47
        if len(config.ToGo) > 0 {
×
NEW
48
                record, err = s.getter.getRecord(ctx, config.ToGo[0])
×
NEW
49
                if err != nil {
×
NEW
50
                        return nil, err
×
51
                }
×
52
        }
53

NEW
54
        return &pbcdp.GetMissingResponse{Missing: []*rcpb.Record{record}}, nil
×
55
}
56

57
// Force the processor to do something
58
func (s *Server) Force(ctx context.Context, req *pbcdp.ForceRequest) (*pbcdp.ForceResponse, error) {
1✔
59
        config, err := s.load(ctx)
1✔
60
        if err != nil {
2✔
61
                return nil, err
1✔
62
        }
1✔
63
        s.hack.Lock()
×
64
        defer s.hack.Unlock()
×
65
        switch req.Type {
×
66
        case pbcdp.ForceRequest_RECREATE_LINKS:
×
67
                return &pbcdp.ForceResponse{}, s.makeLinks(ctx, req.Id, true, config)
×
68
        }
69
        return nil, fmt.Errorf("Unknow force request")
×
70
}
71

72
// ClientUpdate on an updated record
73
func (s *Server) ClientUpdate(ctx context.Context, req *rcpb.ClientUpdateRequest) (*rcpb.ClientUpdateResponse, error) {
×
74
        //return &rcpb.ClientUpdateResponse{}, nil
×
75
        config, err := s.load(ctx)
×
76
        if err != nil {
×
77
                return nil, err
×
78
        }
×
79
        s.hack.Lock()
×
80
        defer s.hack.Unlock()
×
NEW
81

×
NEW
82
        err = s.makeLinks(ctx, req.GetInstanceId(), false, config)
×
NEW
83
        if err == nil {
×
NEW
84
                var ntogo []int32
×
NEW
85
                for _, togo := range config.ToGo {
×
NEW
86
                        if togo != req.GetInstanceId() {
×
NEW
87
                                ntogo = append(ntogo, togo)
×
NEW
88
                        }
×
89
                }
NEW
90
                config.ToGo = ntogo
×
NEW
91
                err = s.save(ctx, config)
×
NEW
92
                if err != nil {
×
NEW
93
                        return nil, err
×
NEW
94
                }
×
NEW
95
        } else {
×
NEW
96
                found := false
×
NEW
97
                for _, togo := range config.ToGo {
×
NEW
98
                        if togo == req.GetInstanceId() {
×
NEW
99
                                found = true
×
NEW
100
                        }
×
101
                }
NEW
102
                if !found {
×
NEW
103
                        config.ToGo = append(config.ToGo, req.GetInstanceId())
×
NEW
104
                        serr := s.save(ctx, config)
×
NEW
105
                        if serr != nil {
×
NEW
106
                                return nil, serr
×
NEW
107
                        }
×
108
                }
109
        }
110

NEW
111
        return &rcpb.ClientUpdateResponse{}, err
×
112
}
113

114
func (s *Server) GetOutstanding(ctx context.Context, req *pbcdp.GetOutstandingRequest) (*pbcdp.GetOutstandingResponse, error) {
×
115
        config, err := s.load(ctx)
×
116
        if err != nil {
×
117
                return nil, err
×
118
        }
×
119

120
        var nums []int32
×
121
        for _, issue := range config.GetIssueMapping() {
×
122
                nums = append(nums, issue)
×
123
        }
×
124

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