FirstID and LastID are not nullable

This commit is contained in:
Ben Visness 2021-07-30 15:01:40 -05:00
parent b0f75675c8
commit 93318c378a
5 changed files with 6 additions and 6 deletions

View File

@ -25,6 +25,6 @@ type Thread struct {
Locked bool `db:"locked"` Locked bool `db:"locked"`
Deleted bool `db:"deleted"` Deleted bool `db:"deleted"`
FirstID *int `db:"first_id"` FirstID int `db:"first_id"`
LastID *int `db:"last_id"` LastID int `db:"last_id"`
} }

View File

@ -505,7 +505,7 @@ func ForumThread(c *RequestContext) ResponseData {
Thread: templates.ThreadToTemplate(&thread), Thread: templates.ThreadToTemplate(&thread),
Posts: posts, Posts: posts,
SubforumUrl: hmnurl.BuildForum(c.CurrentProject.Slug, currentSubforumSlugs, 1), SubforumUrl: hmnurl.BuildForum(c.CurrentProject.Slug, currentSubforumSlugs, 1),
ReplyUrl: hmnurl.BuildForumPostReply(c.CurrentProject.Slug, currentSubforumSlugs, thread.ID, *thread.FirstID), ReplyUrl: hmnurl.BuildForumPostReply(c.CurrentProject.Slug, currentSubforumSlugs, thread.ID, thread.FirstID),
Pagination: pagination, Pagination: pagination,
}, c.Perf) }, c.Perf)
return res return res

View File

@ -156,7 +156,7 @@ func Index(c *RequestContext) ResponseData {
featurable := (!proj.IsHMN() && featurable := (!proj.IsHMN() &&
projectPost.Post.ThreadType == models.ThreadTypeProjectArticle && projectPost.Post.ThreadType == models.ThreadTypeProjectArticle &&
*projectPost.Thread.FirstID == projectPost.Post.ID && projectPost.Thread.FirstID == projectPost.Post.ID &&
landingPageProject.FeaturedPost == nil) landingPageProject.FeaturedPost == nil)
if featurable { if featurable {

View File

@ -78,7 +78,7 @@ func MakePostListItem(
postTypeOptions, found := PostTypeMap[post.ThreadType] postTypeOptions, found := PostTypeMap[post.ThreadType]
if found { if found {
isNotFirst := 0 isNotFirst := 0
if *thread.FirstID != post.ID { if thread.FirstID != post.ID {
isNotFirst = 1 isNotFirst = 1
} }
postType = postTypeOptions[isNotFirst] postType = postTypeOptions[isNotFirst]

View File

@ -51,7 +51,7 @@ func PostToTimelineItem(lineageBuilder *models.SubforumLineageBuilder, post *mod
typeByCatKind, found := TimelineTypeMap[post.ThreadType] typeByCatKind, found := TimelineTypeMap[post.ThreadType]
if found { if found {
isNotFirst := 0 isNotFirst := 0
if *thread.FirstID != post.ID { if thread.FirstID != post.ID {
isNotFirst = 1 isNotFirst = 1
} }
itemType = typeByCatKind[isNotFirst] itemType = typeByCatKind[isNotFirst]