Skip to content

Commit

Permalink
refact: variant index name helper fn
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 31, 2024
1 parent 48e61be commit ff08986
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api/services/ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)),
)
}
Expand Down Expand Up @@ -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))
}

0 comments on commit ff08986

Please sign in to comment.