Skip to content

Commit aa5441c

Browse files
committed
[SP-2993] chore: rename min_cutoff_threshold to recursive_threshold
1 parent 2d56e90 commit aa5441c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

internal/domain/entities/scan_request.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ package entities
44
type ScanRequest struct {
55
// Get results with rank above this threshold (e.g i only want to see results from rank 3 and above)
66
RankThreshold int `validate:"omitempty,min=0"`
7-
// Min cutoff threshold (e.g i only want to see results with score above this threshold)
8-
MinCutoffThreshold float32 `validate:"omitempty,min=0"`
7+
// Recursive threshold (e.g i only want to see results with score above this threshold)
8+
RecursiveThreshold float32 `validate:"omitempty,min=0"`
99
// Filter results by category (e.g i only want to see results from github projects, npm, etc)
1010
Category string
1111
// Maximum number of results to query

internal/mapper/scan_mapper_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (m *ScanMapperImpl) ProtoToDomain(req *scanningv2.HFHRequest) *entities.Sca
2121

2222
return &entities.ScanRequest{
2323
RankThreshold: int(req.RankThreshold),
24-
MinCutoffThreshold: req.MinCutoffThreshold,
24+
RecursiveThreshold: req.RecursiveThreshold,
2525
Category: req.Category,
2626
QueryLimit: int(req.QueryLimit),
2727
Root: m.ChildrenToDomain(req.Root),

internal/service/scan_service_impl.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (s *ScanServiceImpl) ScanFolder(ctx context.Context, req *entities.ScanRequ
2727
return nil, err
2828
}
2929

30-
results, err := s.scanNode(ctx, req.Root, req.RankThreshold, req.MinCutoffThreshold)
30+
results, err := s.scanNode(ctx, req.Root, req.RankThreshold, req.RecursiveThreshold)
3131
if err != nil {
3232
return nil, err
3333
}
@@ -63,7 +63,7 @@ func (s *ScanServiceImpl) processComponentGroups(componentGroups []entities.Comp
6363
return results
6464
}
6565

66-
func (s *ScanServiceImpl) scanNode(ctx context.Context, node *entities.FolderNode, rankThreshold int, minCutoffThreshold float32) ([]*entities.ScanResult, error) {
66+
func (s *ScanServiceImpl) scanNode(ctx context.Context, node *entities.FolderNode, rankThreshold int, recursiveThreshold float32) ([]*entities.ScanResult, error) {
6767
logger := ctxzap.Extract(ctx).Sugar()
6868

6969
if node.SimHashDirNames == "" && node.SimHashNames == "" && node.SimHashContent == "" {
@@ -80,9 +80,9 @@ func (s *ScanServiceImpl) scanNode(ctx context.Context, node *entities.FolderNod
8080

8181
logger.Debugf("SearchByHashes returned %d component groups for node %s", len(componentGroups), node.PathID)
8282

83-
// Check if any component group has a version with score >= minCutoffThreshold
84-
if minCutoffThreshold > 0 && s.hasHighScoreMatch(componentGroups, minCutoffThreshold) {
85-
logger.Infof("Found high score match (>= %f) for node %s, stopping search", minCutoffThreshold, node.PathID)
83+
// Check if any component group has a version with score >= recursiveThreshold
84+
if recursiveThreshold > 0 && s.hasHighScoreMatch(componentGroups, recursiveThreshold) {
85+
logger.Infof("Found high score match (>= %f) for node %s, stopping search", recursiveThreshold, node.PathID)
8686
results := s.processComponentGroups(componentGroups, node.PathID)
8787
return results, nil
8888
}
@@ -91,7 +91,7 @@ func (s *ScanServiceImpl) scanNode(ctx context.Context, node *entities.FolderNod
9191

9292
if len(node.Children) > 0 {
9393
for _, child := range node.Children {
94-
childResults, err := s.scanNode(ctx, child, rankThreshold, minCutoffThreshold)
94+
childResults, err := s.scanNode(ctx, child, rankThreshold, recursiveThreshold)
9595
if err != nil {
9696
return nil, err
9797
}

0 commit comments

Comments
 (0)