FIX: in some cases first_post could be missing

This commit is contained in:
Sam 2018-11-05 10:21:10 +11:00
parent 54dc2b06ca
commit 7673ed2480

View File

@ -221,10 +221,12 @@ SQL
# note, we have canonicals so we only do this for page 1 at the moment
# it can get confusing to have this on every page and it should make page 1
# a bit more prominent + cut down on pointless work
return "" if topic_view.post_number != 1
return "" if !controller.guardian.allow_accepted_answers_on_category?(topic.category_id)
if first_post = topic_view.posts&.first
first_post = topic_view.posts&.first
return "" if first_post&.post_number != 1
question_json = {
'@type' => 'Question',
'name' => topic.title,
@ -237,7 +239,6 @@ SQL
'name' => topic.user&.name
}
}
end
page_json = {
'@type' => 'QAPage',