Use hmndata helpers for project timeline on project homepage
Resolves issue #37
This commit is contained in:
parent
cb71abfdb3
commit
2012328436
|
@ -226,30 +226,11 @@ func ProjectHomepage(c *RequestContext) ResponseData {
|
||||||
c.Perf.EndBlock()
|
c.Perf.EndBlock()
|
||||||
|
|
||||||
c.Perf.StartBlock("SQL", "Fetching project timeline")
|
c.Perf.StartBlock("SQL", "Fetching project timeline")
|
||||||
type postQuery struct {
|
posts, err := hmndata.FetchPosts(c.Context(), c.Conn, c.CurrentUser, hmndata.PostsQuery{
|
||||||
Post models.Post `db:"post"`
|
ProjectIDs: []int{c.CurrentProject.ID},
|
||||||
Thread models.Thread `db:"thread"`
|
Limit: maxRecentActivity,
|
||||||
Author models.User `db:"author"`
|
SortDescending: true,
|
||||||
}
|
})
|
||||||
posts, err := db.Query[postQuery](c.Context(), c.Conn,
|
|
||||||
`
|
|
||||||
SELECT $columns
|
|
||||||
FROM
|
|
||||||
post
|
|
||||||
INNER JOIN thread ON thread.id = post.thread_id
|
|
||||||
INNER JOIN hmn_user AS author ON author.id = post.author_id
|
|
||||||
LEFT JOIN asset AS author_avatar ON author_avatar.id = author.avatar_asset_id
|
|
||||||
WHERE
|
|
||||||
post.project_id = $1
|
|
||||||
ORDER BY post.postdate DESC
|
|
||||||
LIMIT $2
|
|
||||||
`,
|
|
||||||
c.CurrentProject.ID,
|
|
||||||
maxRecentActivity,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch project posts"))
|
|
||||||
}
|
|
||||||
c.Perf.EndBlock()
|
c.Perf.EndBlock()
|
||||||
|
|
||||||
var templateData ProjectHomepageData
|
var templateData ProjectHomepageData
|
||||||
|
@ -326,7 +307,7 @@ func ProjectHomepage(c *RequestContext) ResponseData {
|
||||||
lineageBuilder,
|
lineageBuilder,
|
||||||
&post.Post,
|
&post.Post,
|
||||||
&post.Thread,
|
&post.Thread,
|
||||||
&post.Author,
|
post.Author,
|
||||||
c.Theme,
|
c.Theme,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue