Skip to content

Commit

Permalink
complete config name look-up
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Dec 11, 2021
1 parent a552280 commit eb7da72
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion services/reqmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func ReqMgrUnmarshal(api string, data []byte) []mongo.DASRecord {
type ReqMgrInfo struct {
RequestName string
ConfigIDs []string
ConfigIDMap map[string]string
Tasks []string
}

Expand All @@ -144,6 +145,7 @@ func findReqMgrIds(dasquery dasql.DASQuery, base, dataset string) ([]ReqMgrInfo,
var rurl string
var reqmgrInfo []ReqMgrInfo
idict := make(map[string][]string)
rmap := make(map[string]string)

// check that given dataset pass dataset pattern
matched, err := regexp.MatchString("/[\\w-]+/[\\w-]+/[A-Z-]+", dataset)
Expand Down Expand Up @@ -200,25 +202,32 @@ func findReqMgrIds(dasquery dasql.DASQuery, base, dataset string) ([]ReqMgrInfo,
if !utils.InList(val, ids) {
ids = append(ids, val)
}
rmap[val] = kkk
}
}
}
// extract configs from Task parts of FJR document
if strings.Contains(kkk, "Task") {
switch data := vvv.(type) {
case map[string]interface{}:
var taskName string
if tname, ok := data["TaskName"]; ok {
taskName = fmt.Sprintf("%s", tname)
}
for k, v := range data {
if k == "ConfigCacheID" {
switch tid := v.(type) {
case string:
ids = append(ids, tid)
rmap[tid] = taskName
}
}
}
}
}
}
rinfo.ConfigIDs = utils.List2Set(ids)
rinfo.ConfigIDMap = rmap
reqmgrInfo = append(reqmgrInfo, rinfo)
}
}
Expand Down Expand Up @@ -312,7 +321,18 @@ func reqmgrConfigs(dasquery dasql.DASQuery) []mongo.DASRecord {
rec := make(mongo.DASRecord)
rec["dataset"] = dataset
rec["name"] = req.RequestName
rec["ids"] = req.ConfigIDs
// rec["ids"] = req.ConfigIDs
// construct human readble representation of config ids, i.e.
// we take request config id map and check if proper key exists for given id
var configIds []string
for _, k := range req.ConfigIDs {
if v, ok := req.ConfigIDMap[k]; ok {
configIds = append(configIds, fmt.Sprintf("%s (%s)", k, v))
} else {
configIds = append(configIds, k)
}
}
rec["ids"] = configIds
rec["idict"] = idict
var outputUrls, inputUrls []string
for _, uid := range idict["byinputdataset"] {
Expand Down

0 comments on commit eb7da72

Please sign in to comment.