Fix the length of the array of tags
This commit is contained in:
parent
0783521019
commit
02be9d35b5
1 changed files with 5 additions and 1 deletions
|
@ -122,7 +122,11 @@ func indexHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
|
||||||
_, err := coll.Find(nil).MapReduce(&mr, &result)
|
_, err := coll.Find(nil).MapReduce(&mr, &result)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
sort.Sort(result)
|
sort.Sort(result)
|
||||||
data.Tags = make([]string, len(result))
|
length := len(result)
|
||||||
|
if length > 50 {
|
||||||
|
length = 50
|
||||||
|
}
|
||||||
|
data.Tags = make([]string, length)
|
||||||
for i, tag := range result {
|
for i, tag := range result {
|
||||||
if i == 50 {
|
if i == 50 {
|
||||||
break /* display only 50 */
|
break /* display only 50 */
|
||||||
|
|
Reference in a new issue