Deduplicate project_ids before querying projects for timeline
This commit is contained in:
parent
43a3178b08
commit
966214d03f
|
@ -232,13 +232,18 @@ func FetchTimeline(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectsSeen := make(map[int]bool)
|
||||||
var projectIds []int
|
var projectIds []int
|
||||||
var snippetIds []int
|
var snippetIds []int
|
||||||
projectTargets := make(map[int][]*TimelineItemAndStuff)
|
projectTargets := make(map[int][]*TimelineItemAndStuff)
|
||||||
snippetItems := make(map[int]*TimelineItemAndStuff)
|
snippetItems := make(map[int]*TimelineItemAndStuff)
|
||||||
for _, r := range results {
|
for _, r := range results {
|
||||||
if r.Item.ProjectID != 0 {
|
if r.Item.ProjectID != 0 {
|
||||||
|
if _, found := projectsSeen[r.Item.ProjectID]; !found {
|
||||||
projectIds = append(projectIds, r.Item.ProjectID)
|
projectIds = append(projectIds, r.Item.ProjectID)
|
||||||
|
projectsSeen[r.Item.ProjectID] = true
|
||||||
|
}
|
||||||
|
|
||||||
projectTargets[r.Item.ProjectID] = append(projectTargets[r.Item.ProjectID], r)
|
projectTargets[r.Item.ProjectID] = append(projectTargets[r.Item.ProjectID], r)
|
||||||
}
|
}
|
||||||
if r.Item.Type == models.TimelineItemTypeSnippet {
|
if r.Item.Type == models.TimelineItemTypeSnippet {
|
||||||
|
@ -264,7 +269,10 @@ func FetchTimeline(
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sp := range snippetProjects {
|
for _, sp := range snippetProjects {
|
||||||
|
if _, found := projectsSeen[sp.ProjectID]; !found {
|
||||||
projectIds = append(projectIds, sp.ProjectID)
|
projectIds = append(projectIds, sp.ProjectID)
|
||||||
|
projectsSeen[sp.ProjectID] = true
|
||||||
|
}
|
||||||
projectTargets[sp.ProjectID] = append(projectTargets[sp.ProjectID], snippetItems[sp.SnippetID])
|
projectTargets[sp.ProjectID] = append(projectTargets[sp.ProjectID], snippetItems[sp.SnippetID])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue