From 14fa9431498e7102ba772549570851839df93f4e Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 6 Aug 2020 13:22:55 +0200 Subject: Discussions: Allow discontinuous post numbers + ignore hidden posts in counts/lastpost This solves a few problems: - 'hidden' posts will no longer cause the thread to be bumped to the front page. - Deleting posts will no longer cause other posts to be renumbered (and hence will not break existing links to posts) - Numbers of deleted posts will no longer be re-used (except when they were the last post in the thread - fixing this would require an additional column in 'threads', but it didn't seem worth the trouble) --- lib/VNDB/DB/Discussions.pm | 4 ++-- lib/VNDB/Handler/Misc.pm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/VNDB') diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm index 442f8032..0cc05303 100644 --- a/lib/VNDB/DB/Discussions.pm +++ b/lib/VNDB/DB/Discussions.pm @@ -40,14 +40,14 @@ sub dbThreadGet { } my @select = ( - qw|t.id t.title t.count t.locked t.hidden t.private|, 't.poll_question IS NOT NULL AS haspoll', + qw|t.id t.c_lastnum t.title t.locked t.hidden t.private|, 't.poll_question IS NOT NULL AS haspoll', $o{what} =~ /lastpost/ ? (q|EXTRACT('epoch' from tpl.date) AS lastpost_date|, VNWeb::DB::sql_user('ul', 'lastpost_')) : (), $o{what} =~ /poll/ ? (qw|t.poll_question t.poll_max_options t.poll_preview t.poll_recast|) : (), ); my @join = ( $o{what} =~ /lastpost/ ? ( - 'JOIN threads_posts tpl ON tpl.tid = t.id AND tpl.num = t.count', + 'JOIN threads_posts tpl ON tpl.tid = t.id AND tpl.num = t.c_lastnum', 'JOIN users ul ON ul.id = tpl.uid' ) : (), $o{type} && $o{iid} ? diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index 70588d45..c316999d 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -122,7 +122,7 @@ sub homepage { my $boards = join ', ', map $BOARD_TYPE{$_->{type}}{txt}.($_->{iid}?' > '.$_->{title}:''), @{$_->{boards}}; li; txt fmtage($_->{lastpost_date}).' '; - a href => "/$_->{id}.$_->{count}#last", title => "Posted in $boards", shorten $_->{title}, 25; + a href => "/$_->{id}.$_->{c_lastnum}#last", title => "Posted in $boards", shorten $_->{title}, 25; lit ' by '; VNWeb::HTML::user_($_, 'lastpost_'); end; -- cgit v1.2.3