summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Comment.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Comment.pm')
-rw-r--r--Bugzilla/Comment.pm54
1 files changed, 54 insertions, 0 deletions
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm
index 7c2d5c4ea..911b26775 100644
--- a/Bugzilla/Comment.pm
+++ b/Bugzilla/Comment.pm
@@ -23,6 +23,7 @@ use Bugzilla::Util;
use List::Util qw(first);
use Scalar::Util qw(blessed weaken isweak);
+use Role::Tiny::With;
###############################
#### Initialization ####
@@ -77,6 +78,59 @@ use constant VALIDATOR_DEPENDENCIES => {
isprivate => ['who'],
};
+with 'Bugzilla::Elastic::Role::ChildObject';
+
+use constant ES_TYPE => 'comment';
+use constant ES_PARENT_TYPE => 'bug';
+
+sub ES_OBJECTS_AT_ONCE { 50 }
+
+sub ES_PROPERTIES {
+ return {
+ body => { type => "string", analyzer => 'bz_text_analyzer' },
+ is_private => { type => "boolean" },
+ tags => { type => "string" },
+ };
+}
+
+sub ES_SELECT_UPDATED_SQL {
+ my ($class, $mtime) = @_;
+
+ my $sql = q{
+ SELECT DISTINCT
+ comment_id
+ FROM
+ bugs_activity AS event
+ JOIN
+ fielddefs ON fieldid = fielddefs.id
+ WHERE
+ fielddefs.name = 'longdescs.isprivate'
+ AND bug_when > FROM_UNIXTIME(?)
+ UNION SELECT DISTINCT
+ comment_id
+ FROM
+ longdescs_activity
+ WHERE
+ change_when > FROM_UNIXTIME(?)
+ };
+ return ($sql, [$mtime, $mtime]);
+}
+
+sub es_parent_id {
+ my ($self) = @_;
+
+ return $self->bug_id,
+}
+
+sub es_document {
+ my ($self) = @_;
+
+ return {
+ body => $self->body,
+ is_private => $self->is_private,
+ };
+}
+
#########################
# Database Manipulation #
#########################