diff options
Diffstat (limited to 'skate/zippy.go')
-rw-r--r-- | skate/zippy.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/skate/zippy.go b/skate/zippy.go index 54038c0..7a6902c 100644 --- a/skate/zippy.go +++ b/skate/zippy.go @@ -16,6 +16,7 @@ import ( "log" "sort" "strings" + "time" "git.archive.org/martin/cgraph/skate/set" "git.archive.org/martin/cgraph/skate/zipkey" @@ -378,6 +379,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ continue } var bref BiblioRef + bref.IndexedTs = time.Now().UTC().Format(time.RFC3339) bref.Key = fmt.Sprintf("%s_%d", r.ReleaseIdent, r.Index) bref.RefIndex = r.Index bref.RefKey = r.Key @@ -397,7 +399,9 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ // uniqueMatches takes a list of bref docs (unserialized) and will return a // list of deserialized bref docs, containing unique matches only (e.g. filter -// out things duplicate matches, e.g. from exact and fuzzy). +// out things duplicate matches, e.g. from exact and fuzzy). We are including +// "skate-bref-id" post-processing here as well (but there is surely a better +// place for that). func uniqueMatches(docs []string, stats *statsAugment) (result []*BiblioRef, err error) { var brefs []*BiblioRef for _, doc := range docs { @@ -405,6 +409,11 @@ func uniqueMatches(docs []string, stats *statsAugment) (result []*BiblioRef, err if err := json.Unmarshal([]byte(doc), &bref); err != nil { return nil, err } + // On-the-fly add elasticsearch "_id" and indexed timestamp, if not already set. + if bref.Key == "" && bref.SourceReleaseIdent != "" { + bref.Key = fmt.Sprintf("%s_%d", bref.SourceReleaseIdent, bref.RefIndex) + bref.IndexedTs = time.Now().UTC().Format(time.RFC3339) + } brefs = append(brefs, &bref) } // Make sure exact matches come first. |