summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Comment.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2016-11-20 00:12:39 +0100
committerDylan William Hardison <dylan@hardison.net>2017-01-04 23:30:47 +0100
commit419f3ae9fd57fc4e03146a830f7ed780ace83937 (patch)
treef368b61dab21eb036e4b91e1ec947a4b9eeabae9 /Bugzilla/Comment.pm
parent840bbad83e4672fc84083437e384f0d332020f53 (diff)
downloadbugzilla-419f3ae9fd57fc4e03146a830f7ed780ace83937.tar.gz
bugzilla-419f3ae9fd57fc4e03146a830f7ed780ace83937.tar.xz
Bug 1307478 - Elasticsearch Indexer / Bulk Indexer
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 #
#########################