From 419f3ae9fd57fc4e03146a830f7ed780ace83937 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 19 Nov 2016 18:12:39 -0500 Subject: Bug 1307478 - Elasticsearch Indexer / Bulk Indexer --- Bugzilla/Comment.pm | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'Bugzilla/Comment.pm') 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 # ######################### -- cgit v1.2.3-24-g4f1b