From 0e8435b202264134c964c6f66884a094366b1334 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 18 Feb 2009 21:23:20 +0100 Subject: Don't count deleted threads on number of threads on item pages --- lib/VNDB/DB/Discussions.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/VNDB/DB/Discussions.pm') diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm index 1e626c57..8e476f55 100644 --- a/lib/VNDB/DB/Discussions.pm +++ b/lib/VNDB/DB/Discussions.pm @@ -143,8 +143,10 @@ sub dbThreadCount { my($self, $type, $iid) = @_; return $self->dbRow(q| SELECT COUNT(*) AS cnt - FROM threads_tags - WHERE type = ? AND iid = ?|, + FROM threads_tags tt + JOIN threads t ON t.id = tt.tid + WHERE tt.type = ? AND tt.iid = ? + AND t.hidden = FALSE|, $type, $iid)->{cnt}; } -- cgit v1.2.3 From 79687d7aa222e1ea8d6401d2aaa81c95e58c5b85 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 21 Mar 2009 14:51:18 +0100 Subject: Replacing all occurences of 'discussion tags' with 'discussion boards' Which is a more accurate description, and doesn't confuse with the tagging system. Note than even all internal uses of the word 'tag' have been replaced, as I'm not a huge fan of different terminology in the code and UI. This update might break some things related to the discussion board. --- lib/VNDB/DB/Discussions.pm | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'lib/VNDB/DB/Discussions.pm') diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm index 1e626c57..7daf2f25 100644 --- a/lib/VNDB/DB/Discussions.pm +++ b/lib/VNDB/DB/Discussions.pm @@ -9,7 +9,7 @@ our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPos # Options: id, type, iid, results, page, what -# What: tags, tagtitles, firstpost, lastpost +# What: boards, boardtitles, firstpost, lastpost sub dbThreadGet { my($self, %o) = @_; $o{results} ||= 50; @@ -23,9 +23,9 @@ sub dbThreadGet { !$o{id} ? ( 't.hidden = FALSE' => 0 ) : (), $o{type} && !$o{iid} ? ( - 't.id IN(SELECT tid FROM threads_tags WHERE type = ?)' => $o{type} ) : (), + 't.id IN(SELECT tid FROM threads_boards WHERE type = ?)' => $o{type} ) : (), $o{type} && $o{iid} ? ( - 'tt.type = ?' => $o{type}, 'tt.iid = ?' => $o{iid} ) : (), + 'tb.type = ?' => $o{type}, 'tb.iid = ?' => $o{iid} ) : (), ); my @select = ( @@ -44,7 +44,7 @@ sub dbThreadGet { 'JOIN users ul ON ul.id = tpl.uid' ) : (), $o{type} && $o{iid} ? - 'JOIN threads_tags tt ON tt.tid = t.id' : (), + 'JOIN threads_boards tb ON tb.tid = t.id' : (), ); my($r, $np) = $self->dbPage(\%o, q| @@ -56,30 +56,30 @@ sub dbThreadGet { join(', ', @select), join(' ', @join), \%where, $o{order} ); - if($o{what} =~ /(tags|tagtitles)/ && $#$r >= 0) { + if($o{what} =~ /(boards|boardtitles)/ && $#$r >= 0) { my %r = map { - $r->[$_]{tags} = []; + $r->[$_]{boards} = []; ($r->[$_]{id}, $_) } 0..$#$r; - if($o{what} =~ /tags/) { - ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, [ $_->{type}, $_->{iid} ]) for (@{$self->dbAll(q| + if($o{what} =~ /boards/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{boards}}, [ $_->{type}, $_->{iid} ]) for (@{$self->dbAll(q| SELECT tid, type, iid - FROM threads_tags + FROM threads_boards WHERE tid IN(!l)|, [ keys %r ] )}); } - if($o{what} =~ /tagtitles/) { - ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, $_) for (@{$self->dbAll(q| - SELECT tt.tid, tt.type, tt.iid, COALESCE(u.username, vr.title, pr.name) AS title, COALESCE(u.username, vr.original, pr.original) AS original - FROM threads_tags tt - LEFT JOIN vn v ON tt.type = 'v' AND v.id = tt.iid + if($o{what} =~ /boardtitles/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{boards}}, $_) for (@{$self->dbAll(q| + SELECT tb.tid, tb.type, tb.iid, COALESCE(u.username, vr.title, pr.name) AS title, COALESCE(u.username, vr.original, pr.original) AS original + FROM threads_boards tb + LEFT JOIN vn v ON tb.type = 'v' AND v.id = tb.iid LEFT JOIN vn_rev vr ON vr.id = v.latest - LEFT JOIN producers p ON tt.type = 'p' AND p.id = tt.iid + LEFT JOIN producers p ON tb.type = 'p' AND p.id = tb.iid LEFT JOIN producers_rev pr ON pr.id = p.latest - LEFT JOIN users u ON tt.type = 'u' AND u.id = tt.iid - WHERE tt.tid IN(!l)|, + LEFT JOIN users u ON tb.type = 'u' AND u.id = tb.iid + WHERE tb.tid IN(!l)|, [ keys %r ] )}); } @@ -89,7 +89,7 @@ sub dbThreadGet { } -# id, %options->( title locked hidden tags } +# id, %options->( title locked hidden boards } sub dbThreadEdit { my($self, $id, %o) = @_; @@ -105,18 +105,18 @@ sub dbThreadEdit { WHERE id = ?|, \%set, $id); - if($o{tags}) { - $self->dbExec('DELETE FROM threads_tags WHERE tid = ?', $id); + if($o{boards}) { + $self->dbExec('DELETE FROM threads_boards WHERE tid = ?', $id); $self->dbExec(q| - INSERT INTO threads_tags (tid, type, iid) + INSERT INTO threads_boards (tid, type, iid) VALUES (?, ?, ?)|, $id, $_->[0], $_->[1]||0 - ) for (@{$o{tags}}); + ) for (@{$o{boards}}); } } -# %options->{ title hidden locked tags } +# %options->{ title hidden locked boards } sub dbThreadAdd { my($self, %o) = @_; @@ -128,22 +128,22 @@ sub dbThreadAdd { )->{id}; $self->dbExec(q| - INSERT INTO threads_tags (tid, type, iid) + INSERT INTO threads_boards (tid, type, iid) VALUES (?, ?, ?)|, $id, $_->[0], $_->[1]||0 - ) for (@{$o{tags}}); + ) for (@{$o{boards}}); return $id; } -# Returns thread count of a specific item tag +# Returns thread count of a specific item board # Arguments: type, iid sub dbThreadCount { my($self, $type, $iid) = @_; return $self->dbRow(q| SELECT COUNT(*) AS cnt - FROM threads_tags + FROM threads_boards WHERE type = ? AND iid = ?|, $type, $iid)->{cnt}; } -- cgit v1.2.3