From ea7b2a4a7c08efba72ddbbb0d73c1aa1283146da Mon Sep 17 00:00:00 2001 From: Valentin Kuznetsov Date: Tue, 22 Mar 2022 14:44:20 -0400 Subject: [PATCH] adjust to new DBS Go server for lumis output --- services/helpers.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/services/helpers.go b/services/helpers.go index e98c716..7e22f7f 100644 --- a/services/helpers.go +++ b/services/helpers.go @@ -313,18 +313,29 @@ func OrderByRunLumis(records []mongo.DASRecord) []mongo.DASRecord { var out []mongo.DASRecord rmap := make(map[json.Number][]json.Number) for _, r := range records { - lumiList := mongo.GetValue(r, "lumi.number").([]interface{}) + var lumiList []json.Number + switch v := mongo.GetValue(r, "lumi.number").(type) { + case json.Number: + lumiList = append(lumiList, v) + case []interface{}: + for _, vv := range v { + lumiList = append(lumiList, vv.(json.Number)) + } + } + // lumiList := mongo.GetValue(r, "lumi.number").([]interface{}) run := mongo.GetValue(r, "run.run_number").(json.Number) lumis, ok := rmap[run] if ok { for _, v := range lumiList { - lumis = append(lumis, v.(json.Number)) + // lumis = append(lumis, v.(json.Number)) + lumis = append(lumis, v) } rmap[run] = lumis } else { var lumiValues []json.Number for _, v := range lumiList { - lumiValues = append(lumiValues, v.(json.Number)) + // lumiValues = append(lumiValues, v.(json.Number)) + lumiValues = append(lumiValues, v) } rmap[run] = lumiValues }