Search was not scrolling fine

This commit is contained in:
Las Zenow 2012-08-24 20:18:16 +02:00
parent 4762f09df3
commit ea906a7681
3 changed files with 3 additions and 7 deletions

View file

@ -41,7 +41,7 @@ func GetBook(coll *mgo.Collection, query bson.M, r ...int) (books []Book, num in
start = r[1]
}
}
q := coll.Find(query)
q := coll.Find(query).Sort("-_id")
num, err = q.Count()
if err != nil {
return

View file

@ -50,7 +50,7 @@ func searchHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request
page = 0
}
}
res, num, _ := GetBook(coll, buildQuery(req), SEARCH_ITEMS_PAGE, page)
res, num, _ := GetBook(coll, buildQuery(req), SEARCH_ITEMS_PAGE, page*SEARCH_ITEMS_PAGE)
var data searchData
data.S = GetStatus(w, r)

View file

@ -103,11 +103,7 @@ func indexHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
data.S = GetStatus(w, r)
data.S.Home = true
data.Count, _ = coll.Count()
coll.Find(bson.M{}).Sort("-_id").Limit(6).All(&data.Books)
for i, b := range data.Books {
data.Books[i].Id = bson.ObjectId(b.Id).Hex()
}
data.Books, data.Count, _ = GetBook(coll, bson.M{}, 6)
loadTemplate(w, "index", data)
}
}