From c72f8dc787379f6544739c5c57a8241a14f6d2a0 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 9 May 2024 19:12:52 +0200 Subject: style: rename Option.Option to Option.Name --- frontend/templates/blocks/options.gotmpl | 4 ++-- internal/importer/ingest.go | 2 +- internal/options/option.go | 2 +- internal/search/indexer.go | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/templates/blocks/options.gotmpl b/frontend/templates/blocks/options.gotmpl index a9c2a1b..f27e8e6 100644 --- a/frontend/templates/blocks/options.gotmpl +++ b/frontend/templates/blocks/options.gotmpl @@ -4,9 +4,9 @@
{{- range .Results.Hits }} {{- with .Data }} -
+
- {{ .Option }} + {{ .Name }}

{{ markdown .Description }} diff --git a/internal/importer/ingest.go b/internal/importer/ingest.go index b9db80c..3d6854d 100644 --- a/internal/importer/ingest.go +++ b/internal/importer/ingest.go @@ -220,7 +220,7 @@ func (i *OptionIngester) Process(ctx context.Context) (<-chan *options.NixOption // slog.Debug("sending option", "name", kv.Key) results <- &options.NixOption{ - Option: kv.Key, + Name: kv.Key, Source: strings.ToLower(i.source.Name), Declarations: decs, Default: convertNixValue(i.optJSON.Default), diff --git a/internal/options/option.go b/internal/options/option.go index b7fe818..a93b4e2 100644 --- a/internal/options/option.go +++ b/internal/options/option.go @@ -13,7 +13,7 @@ type Link struct { } type NixOption struct { - Option string + Name string Source string Declarations []Link diff --git a/internal/search/indexer.go b/internal/search/indexer.go index ad891ff..0ff041f 100644 --- a/internal/search/indexer.go +++ b/internal/search/indexer.go @@ -122,7 +122,7 @@ func NewIndexer(indexPath string, force bool) (*WriteIndex, error) { optionMapping := bleve.NewDocumentStaticMapping() - optionMapping.AddFieldMappingsAt("Option", keywordFieldMapping) + optionMapping.AddFieldMappingsAt("Name", keywordFieldMapping) optionMapping.AddFieldMappingsAt("Source", keywordFieldMapping) optionMapping.AddFieldMappingsAt("Loc", locFieldMapping) optionMapping.AddFieldMappingsAt("RelatedPackages", textFieldMapping) @@ -165,10 +165,10 @@ func (i *WriteIndex) ImportOptions( default: } - doc := document.NewDocument(opt.Source + "/" + opt.Option) + doc := document.NewDocument(opt.Source + "/" + opt.Name) err = i.indexMapping.MapDocument(doc, opt) if err != nil { - errs <- errors.WithMessagef(err, "could not map document for option: %s", opt.Option) + errs <- errors.WithMessagef(err, "could not map document for option: %s", opt.Name) continue } @@ -184,11 +184,11 @@ func (i *WriteIndex) ImportOptions( field := document.NewTextFieldWithIndexingOptions("_data", nil, data.Bytes(), index.StoreField) newDoc := doc.AddField(field) - // slog.Debug("adding option to index", "name", opt.Option) + // slog.Debug("adding option to index", "name", opt.Name) err = batch.IndexAdvanced(newDoc) if err != nil { - errs <- errors.WithMessagef(err, "could not index option %s", opt.Option) + errs <- errors.WithMessagef(err, "could not index option %s", opt.Name) continue } -- cgit 1.4.1