aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-06-15 04:32:53 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-06-15 04:32:53 +0200
commit6a151510dac7985a4825d5e05539063a2ce6a610 (patch)
tree4229edc156269556923d6cc84b0d4b81ca531ac8
parentaa54a8e4f027a22145610cca784686345589b9f8 (diff)
downloadrefcat-6a151510dac7985a4825d5e05539063a2ce6a610.tar.gz
refcat-6a151510dac7985a4825d5e05539063a2ce6a610.zip
zippy: include raw ref when unmatched for debugging
-rw-r--r--skate/schema.go3
-rw-r--r--skate/zippy.go1
-rw-r--r--skate/zippy_test.go17
3 files changed, 19 insertions, 2 deletions
diff --git a/skate/schema.go b/skate/schema.go
index d36a771..7f707f3 100644
--- a/skate/schema.go
+++ b/skate/schema.go
@@ -345,6 +345,9 @@ type BiblioRef struct {
MatchReason string `json:"match_reason,omitempty"`
TargetUnstructured string `json:"target_unstructured,omitempty"`
TargetCSL string `json:"target_csl,omitempty"`
+ Extra struct {
+ Ref Ref `json:"ref"` // keep the raw original ref around (e.g. for unmatched)
+ } `json:"extra"`
}
// ReleaseCluster, a list of match candidates. This is typically serialized as a
diff --git a/skate/zippy.go b/skate/zippy.go
index 2283733..69877b7 100644
--- a/skate/zippy.go
+++ b/skate/zippy.go
@@ -388,6 +388,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [
// Reuse fields for debugging, for now.
bref.MatchStatus = StatusUnmatched.Short()
bref.MatchReason = ReasonUnknown.Short()
+ bref.Extra.Ref = *r
matched = append(matched, &bref)
}
return matched
diff --git a/skate/zippy_test.go b/skate/zippy_test.go
index 16aa74d..817626b 100644
--- a/skate/zippy_test.go
+++ b/skate/zippy_test.go
@@ -193,6 +193,18 @@ func TestMatchedRefsExtend(t *testing.T) {
MatchStatus: StatusUnmatched.Short(),
MatchReason: ReasonUnknown.Short(),
SourceYear: "0",
+ Extra: struct {
+ Ref Ref `json:"ref"`
+ }{
+ Ref: Ref{
+ ReleaseIdent: "0000",
+ Biblio: Biblio{
+ Title: "Title",
+ },
+ Index: 3,
+ Key: "K3",
+ },
+ },
},
},
},
@@ -223,10 +235,11 @@ func TestMatchedRefsExtend(t *testing.T) {
},
},
}
- for _, c := range cases {
+ for i, c := range cases {
result := matchedRefsExtend(c.matched, c.refs, &statsAugment{})
if !reflect.DeepEqual(result, c.result) {
- t.Fatalf("got %v, want %v (%v)", result, c.result, pretty.Diff(result, c.result))
+ t.Fatalf("[%d]: got %v, want %v (%v)",
+ i+1, result, c.result, pretty.Diff(result, c.result))
}
}
}