Fix intersection of search results

This commit is contained in:
Ingo Oppermann
2022-08-19 12:37:53 +03:00
parent f60d09963c
commit 45fa1c4498

View File

@@ -826,6 +826,7 @@ func (r *restream) GetProcessIDs(idpattern, refpattern string) []string {
} }
idmap := map[string]int{} idmap := map[string]int{}
count := 0
if len(idpattern) != 0 { if len(idpattern) != 0 {
for id := range r.tasks { for id := range r.tasks {
@@ -838,8 +839,10 @@ func (r *restream) GetProcessIDs(idpattern, refpattern string) []string {
continue continue
} }
idmap[id] = 1 idmap[id]++
} }
count++
} }
if len(refpattern) != 0 { if len(refpattern) != 0 {
@@ -853,22 +856,20 @@ func (r *restream) GetProcessIDs(idpattern, refpattern string) []string {
continue continue
} }
if _, ok := idmap[t.id]; ok { idmap[t.id]++
idmap[t.id]++
}
} }
count++
} }
ids := make([]string, len(idmap)) ids := []string{}
i := 0
for id, count := range idmap { for id, n := range idmap {
if count == 1 { if n != count {
continue continue
} }
ids[i] = id ids = append(ids, id)
i++
} }
return ids return ids