Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add some more to comment bitmap API

Not in use yet
  • Loading branch information...
commit d23d473bdea5efd2fb50d5f465f3cc3dbd98d871 1 parent d872f5e
Chris Nandor authored June 19, 2008
45  Slash/Utility/Comments/Comments.pm
@@ -37,6 +37,7 @@ our @EXPORT  = qw(
37 37
 	constrain_score dispComment displayThread printComments
38 38
 	jsSelectComments commentCountThreshold commentThresholds discussion2
39 39
 	selectComments preProcessReplyForm makeCommentBitmap parseCommentBitmap
  40
+	saveCommentBitmap getCommentBitmap saveCommentReadLog
40 41
 	getPoints preProcessComment postProcessComment prevComment saveComment
41 42
 );
42 43
 
@@ -560,6 +561,50 @@ sub _get_thread {
560 561
 	return $newcomments;
561 562
 }
562 563
 
  564
+sub saveCommentReadLog {
  565
+	my($comments, $discussion_id, $uid) = @_;
  566
+
  567
+	$uid ||= getCurrentUser('uid');
  568
+	my $slashdb = getCurrentDB();
  569
+
  570
+	# cache inserts?
  571
+	for my $cid (@$comments) {
  572
+		$slashdb->sqlInsert('users_comments_read_log', {
  573
+			uid            => $uid,
  574
+			discussion_id  => $discussion_id,
  575
+			cid            => $cid
  576
+		}, { ignore => 1 });
  577
+	}
  578
+}
  579
+
  580
+
  581
+sub getCommentBitmap {
  582
+	my($discussion_id, $uid) = @_;
  583
+
  584
+	$uid ||= getCurrentUser('uid');
  585
+	my $slashdb = getCurrentDB(); # is reader fast enough to be useful?
  586
+
  587
+	my $bitmap = $slashdb->sqlSelect('comment_bitmap', 'users_comments_read',
  588
+		'uid=' . $slashdb->sqlQuote($uid) . ' AND discussion_id=' .
  589
+		$slashdb->sqlQuote($discussion_id)
  590
+	);
  591
+
  592
+	return $bitmap;
  593
+}
  594
+
  595
+sub saveCommentBitmap {
  596
+	my($bitmap, $discussion_id, $uid) = @_;
  597
+
  598
+	$uid ||= getCurrentUser('uid');
  599
+	my $slashdb = getCurrentDB();
  600
+
  601
+	$slashdb->sqlReplace('users_comments_read', {
  602
+		uid            => $uid,
  603
+		discussion_id  => $discussion_id,
  604
+		comment_bitmap => $bitmap
  605
+	});
  606
+}
  607
+
563 608
 sub parseCommentBitmap {
564 609
 	my($bitmap) = @_;
565 610
 	return {} unless $bitmap;
29  sql/mysql/slashschema_create.sql
@@ -1393,6 +1393,35 @@ CREATE TABLE users_comments (
1393 1393
 ) TYPE=InnoDB;
1394 1394
 
1395 1395
 #
  1396
+# Table structure for table 'users_comments_read'
  1397
+#
  1398
+
  1399
+DROP TABLE IF EXISTS users_comments_read;
  1400
+CREATE TABLE users_comments_read (
  1401
+	read_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  1402
+	uid MEDIUMINT UNSIGNED NOT NULL,
  1403
+	discussion_id MEDIUMINT UNSIGNED NOT NULL,
  1404
+	comment_bitmap MEDIUMBLOB,
  1405
+	PRIMARY KEY (read_id),
  1406
+	UNIQUE uid_key (uid,discussion_id)
  1407
+) TYPE=InnoDB;
  1408
+
  1409
+#
  1410
+# Table structure for table 'users_comments_read_log'
  1411
+#
  1412
+
  1413
+DROP TABLE IF EXISTS users_comments_read_log;
  1414
+CREATE TABLE users_comments_read_log (
  1415
+	read_log_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  1416
+	uid MEDIUMINT UNSIGNED NOT NULL,
  1417
+	discussion_id MEDIUMINT UNSIGNED NOT NULL,
  1418
+	cid INT UNSIGNED NOT NULL,
  1419
+	PRIMARY KEY (read_log_id),
  1420
+	UNIQUE uid_key (uid,discussion_id,cid)
  1421
+) TYPE=InnoDB;
  1422
+
  1423
+
  1424
+#
1396 1425
 # Table structure for table 'users_hits'
1397 1426
 #
1398 1427
 

0 notes on commit d23d473

Please sign in to comment.
Something went wrong with that request. Please try again.