mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-06-05 23:03:55 +00:00
fix(pattern): add nil check and fmt import for GetPatternInsight
- [x] Add `fmt` import for error formatting - [x] Add nil check for pattern before using it - [x] Remove duplicate comment line
This commit is contained in:
@@ -3,6 +3,7 @@ package pattern
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -370,12 +371,16 @@ func (d *Detector) CandidateCount() int {
|
|||||||
return len(d.candidates)
|
return len(d.candidates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPatternInsight returns a formatted insight string for a pattern.
|
||||||
// GetPatternInsight returns a formatted insight string for a pattern.
|
// GetPatternInsight returns a formatted insight string for a pattern.
|
||||||
func (d *Detector) GetPatternInsight(ctx context.Context, patternID int64) (string, error) {
|
func (d *Detector) GetPatternInsight(ctx context.Context, patternID int64) (string, error) {
|
||||||
pattern, err := d.patternStore.GetPatternByID(ctx, patternID)
|
pattern, err := d.patternStore.GetPatternByID(ctx, patternID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if pattern == nil {
|
||||||
|
return "", fmt.Errorf("pattern not found: %d", patternID)
|
||||||
|
}
|
||||||
|
|
||||||
return formatPatternInsight(pattern), nil
|
return formatPatternInsight(pattern), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user