Merge 623201588e
into 72fa575fee
This commit is contained in:
commit
3a66716fad
1 changed files with 2 additions and 2 deletions
|
@ -2044,7 +2044,7 @@ func (db *datastore) GetTopPosts(u *User, alias string, hostName string) (*[]Pub
|
||||||
where = " AND alias = ?"
|
where = " AND alias = ?"
|
||||||
params = append(params, alias)
|
params = append(params, alias)
|
||||||
}
|
}
|
||||||
rows, err := db.Query("SELECT p.id, p.slug, p.view_count, p.title, p.content, c.alias, c.title, c.description, c.view_count FROM posts p LEFT JOIN collections c ON p.collection_id = c.id WHERE p.owner_id = ?"+where+" ORDER BY p.view_count DESC, created DESC LIMIT 25", params...)
|
rows, err := db.Query("SELECT p.id, p.slug, p.view_count, p.title, p.content, c.alias, c.title, c.description, c.view_count, count(*) like_count FROM posts p LEFT JOIN collections c ON p.collection_id = c.id LEFT JOIN remote_likes l ON p.id=l.post_id WHERE p.owner_id = ?"+where+" GROUP BY p.id ORDER BY p.view_count, like_count DESC, p.created DESC LIMIT 25", params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed selecting from posts: %v", err)
|
log.Error("Failed selecting from posts: %v", err)
|
||||||
return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve user top posts."}
|
return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve user top posts."}
|
||||||
|
@ -2058,7 +2058,7 @@ func (db *datastore) GetTopPosts(u *User, alias string, hostName string) (*[]Pub
|
||||||
c := Collection{}
|
c := Collection{}
|
||||||
var alias, title, description sql.NullString
|
var alias, title, description sql.NullString
|
||||||
var views sql.NullInt64
|
var views sql.NullInt64
|
||||||
err = rows.Scan(&p.ID, &p.Slug, &p.ViewCount, &p.Title, &p.Content, &alias, &title, &description, &views)
|
err = rows.Scan(&p.ID, &p.Slug, &p.ViewCount, &p.Title, &p.Content, &alias, &title, &description, &views, &p.LikeCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed scanning User.getPosts() row: %v", err)
|
log.Error("Failed scanning User.getPosts() row: %v", err)
|
||||||
gotErr = true
|
gotErr = true
|
||||||
|
|
Loading…
Add table
Reference in a new issue