swap TopicCountInForums's implementation out for a saner one...

clean up repetition in route legends
This commit is contained in:
Azareal 2020-02-29 17:34:38 +10:00
parent ae8c27fc2d
commit b1c9e0d11c
2 changed files with 12 additions and 7 deletions

View File

@ -402,5 +402,8 @@ func ArgQToTopicCount(argList []interface{}, qlist string) (topicCount int, err
} }
func TopicCountInForums(forums []Forum) (topicCount int, err error) { func TopicCountInForums(forums []Forum) (topicCount int, err error) {
return ArgQToTopicCount(ForumListToArgQ(forums)) for _, f := range forums {
topicCount += f.TopicCount
}
return topicCount, nil
} }

View File

@ -834,7 +834,7 @@ func AnalyticsRoutesPerf(w http.ResponseWriter, r *http.Request, user c.User) c.
if inEx(ovitem.name) { if inEx(ovitem.name) {
continue continue
} }
if strings.HasPrefix(ovitem.name,"panel.") { if strings.HasPrefix(ovitem.name, "panel.") {
continue continue
} }
var viewList []int64 var viewList []int64
@ -842,8 +842,9 @@ func AnalyticsRoutesPerf(w http.ResponseWriter, r *http.Request, user c.User) c.
viewList = append(viewList, ovitem.viewMap[value]) viewList = append(viewList, ovitem.viewMap[value])
} }
vList = append(vList, viewList) vList = append(vList, viewList)
legendList = append(legendList, ovitem.name) shortName := strings.Replace(ovitem.name, "routes.", "r.", -1)
if i >= 6 { legendList = append(legendList, shortName)
if i >= 7 {
break break
} }
i++ i++
@ -860,7 +861,7 @@ func AnalyticsRoutesPerf(w http.ResponseWriter, r *http.Request, user c.User) c.
cv, cu := c.ConvertPerfUnit(float64(count)) cv, cu := c.ConvertPerfUnit(float64(count))
routeItems = append(routeItems, c.PanelAnalyticsRoutesPerfItem{ routeItems = append(routeItems, c.PanelAnalyticsRoutesPerfItem{
Route: route, Route: route,
Unit: cu, Unit: cu,
Count: int(cv), Count: int(cv),
}) })
} }
@ -1082,8 +1083,9 @@ func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user c.User) c.Rout
viewList = append(viewList, ovitem.viewMap[value]) viewList = append(viewList, ovitem.viewMap[value])
} }
vList = append(vList, viewList) vList = append(vList, viewList)
legendList = append(legendList, ovitem.name) shortName := strings.Replace(ovitem.name, "routes.", "r.", -1)
if i >= 6 { legendList = append(legendList, shortName)
if i >= 7 {
break break
} }
i++ i++