Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add some more to comment bitmap API

Not in use yet
  • Loading branch information...
commit d23d473bdea5efd2fb50d5f465f3cc3dbd98d871 1 parent d872f5e
@pudge pudge authored
View
45 Slash/Utility/Comments/Comments.pm
@@ -37,6 +37,7 @@ our @EXPORT = qw(
constrain_score dispComment displayThread printComments
jsSelectComments commentCountThreshold commentThresholds discussion2
selectComments preProcessReplyForm makeCommentBitmap parseCommentBitmap
+ saveCommentBitmap getCommentBitmap saveCommentReadLog
getPoints preProcessComment postProcessComment prevComment saveComment
);
@@ -560,6 +561,50 @@ sub _get_thread {
return $newcomments;
}
+sub saveCommentReadLog {
+ my($comments, $discussion_id, $uid) = @_;
+
+ $uid ||= getCurrentUser('uid');
+ my $slashdb = getCurrentDB();
+
+ # cache inserts?
+ for my $cid (@$comments) {
+ $slashdb->sqlInsert('users_comments_read_log', {
+ uid => $uid,
+ discussion_id => $discussion_id,
+ cid => $cid
+ }, { ignore => 1 });
+ }
+}
+
+
+sub getCommentBitmap {
+ my($discussion_id, $uid) = @_;
+
+ $uid ||= getCurrentUser('uid');
+ my $slashdb = getCurrentDB(); # is reader fast enough to be useful?
+
+ my $bitmap = $slashdb->sqlSelect('comment_bitmap', 'users_comments_read',
+ 'uid=' . $slashdb->sqlQuote($uid) . ' AND discussion_id=' .
+ $slashdb->sqlQuote($discussion_id)
+ );
+
+ return $bitmap;
+}
+
+sub saveCommentBitmap {
+ my($bitmap, $discussion_id, $uid) = @_;
+
+ $uid ||= getCurrentUser('uid');
+ my $slashdb = getCurrentDB();
+
+ $slashdb->sqlReplace('users_comments_read', {
+ uid => $uid,
+ discussion_id => $discussion_id,
+ comment_bitmap => $bitmap
+ });
+}
+
sub parseCommentBitmap {
my($bitmap) = @_;
return {} unless $bitmap;
View
29 sql/mysql/slashschema_create.sql
@@ -1393,6 +1393,35 @@ CREATE TABLE users_comments (
) TYPE=InnoDB;
#
+# Table structure for table 'users_comments_read'
+#
+
+DROP TABLE IF EXISTS users_comments_read;
+CREATE TABLE users_comments_read (
+ read_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ uid MEDIUMINT UNSIGNED NOT NULL,
+ discussion_id MEDIUMINT UNSIGNED NOT NULL,
+ comment_bitmap MEDIUMBLOB,
+ PRIMARY KEY (read_id),
+ UNIQUE uid_key (uid,discussion_id)
+) TYPE=InnoDB;
+
+#
+# Table structure for table 'users_comments_read_log'
+#
+
+DROP TABLE IF EXISTS users_comments_read_log;
+CREATE TABLE users_comments_read_log (
+ read_log_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ uid MEDIUMINT UNSIGNED NOT NULL,
+ discussion_id MEDIUMINT UNSIGNED NOT NULL,
+ cid INT UNSIGNED NOT NULL,
+ PRIMARY KEY (read_log_id),
+ UNIQUE uid_key (uid,discussion_id,cid)
+) TYPE=InnoDB;
+
+
+#
# Table structure for table 'users_hits'
#
Please sign in to comment.
Something went wrong with that request. Please try again.