From ff08986ca2c7c62c1d3370e5ec2ecb7ac4086aa3 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Thu, 31 Oct 2024 14:08:21 -0400 Subject: [PATCH] refact: variant index name helper fn --- src/api/services/ingestion.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/services/ingestion.go b/src/api/services/ingestion.go index caefbb9..ca2dc62 100644 --- a/src/api/services/ingestion.go +++ b/src/api/services/ingestion.go @@ -142,7 +142,7 @@ func (i *IngestionService) Init() { esutil.BulkIndexerItem{ // Action field configures the operation to perform (index, create, delete, update) Action: "index", - Index: fmt.Sprintf("variants-%s", strings.ToLower(queuedVariant.Chrom)), + Index: variantIndexName(queuedVariant.Chrom), // Body is an `io.Reader` with the payload Body: bytes.NewReader(variantData), @@ -424,7 +424,7 @@ func (i *IngestionService) ProcessVcf( var createBody = fmt.Sprintf(`{"mappings": %s}`, mappings) client.Indices.Create( - "variants-"+c, + variantIndexName(c), client.Indices.Create.WithBody(strings.NewReader(createBody)), ) } @@ -886,3 +886,7 @@ func (i *IngestionService) FilenameAlreadyRunning(filename string) bool { } return false } + +func variantIndexName(contig string) string { + return fmt.Sprintf("variants-%s", strings.ToLower(contig)) +}