Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address comments #88

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions handler/cantabular_metadata_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,33 @@ func (h *CantabularMetadataExport) Handle(ctx context.Context, workerID int, msg
}
}
for _, dim := range dims {
if filterOutput.Type == multivariate && !*dim.IsAreaType {
nonAreaTypeDimension := dataset.VersionDimension{
Name: dim.Name,
URL: fmt.Sprintf("%s/code-lists/%s", h.cfg.ExternalPrefixURL, strings.ToLower(dim.Name)),
Label: dim.Label,
Description: dim.Description,
ID: dim.ID,
NumberOfOptions: dim.NumberOfOptions,
QualityStatementText: dim.QualityStatementText,
if dim.IsAreaType != nil {
if filterOutput.Type == multivariate && !*dim.IsAreaType {
nonAreaTypeDimension := dataset.VersionDimension{
Name: dim.Name,
URL: fmt.Sprintf("%s/code-lists/%s", h.cfg.ExternalPrefixURL, strings.ToLower(dim.Name)),
Label: dim.Label,
Description: dim.Description,
ID: dim.ID,
NumberOfOptions: dim.NumberOfOptions,
QualityStatementText: dim.QualityStatementText,
}
m.Version.Dimensions = append(m.Version.Dimensions, nonAreaTypeDimension)
m.CSVHeader = append(m.CSVHeader, dim.Name)
}
m.Version.Dimensions = append(m.Version.Dimensions, nonAreaTypeDimension)
m.CSVHeader = append(m.CSVHeader, dim.Name)
}
if dim.IsAreaType != nil && *dim.IsAreaType {
areaTypeDimension := dataset.VersionDimension{
Name: dim.Name,
URL: fmt.Sprintf("%s/code-lists/%s", h.cfg.ExternalPrefixURL, strings.ToLower(dim.Name)),
Label: dim.Label,
Description: dim.Description,
ID: dim.ID,
NumberOfOptions: dim.NumberOfOptions,
QualityStatementText: dim.QualityStatementText,
if *dim.IsAreaType {
areaTypeDimension := dataset.VersionDimension{
Name: dim.Name,
URL: fmt.Sprintf("%s/code-lists/%s", h.cfg.ExternalPrefixURL, strings.ToLower(dim.Name)),
Label: dim.Label,
Description: dim.Description,
ID: dim.ID,
NumberOfOptions: dim.NumberOfOptions,
QualityStatementText: dim.QualityStatementText,
}
m.Version.Dimensions = append(m.Version.Dimensions, areaTypeDimension)
m.CSVHeader = append(m.CSVHeader, dim.Name)
}
m.Version.Dimensions = append(m.Version.Dimensions, areaTypeDimension)
m.CSVHeader = append(m.CSVHeader, dim.Name)
}
}
m.Version.Dimensions = removeDuplicateDimensions(m.Version.Dimensions)
Expand Down Expand Up @@ -509,11 +511,11 @@ func (h *CantabularMetadataExport) GetFilterDimensions(ctx context.Context, filt
}

func removeDuplicateDimensions(vDims []dataset.VersionDimension) []dataset.VersionDimension {
allDims := make(map[dataset.VersionDimension]bool)
allDims := make(map[string]bool)
dimensions := []dataset.VersionDimension{}
for _, dims := range vDims {
if _, dim := allDims[dims]; !dim {
allDims[dims] = true
if !allDims[dims.ID] {
allDims[dims.ID] = true
dimensions = append(dimensions, dims)
}
}
Expand Down