diff options
author | Mario de la Ossa <mariodelaossa@gmail.com> | 2019-06-11 22:35:19 -0600 |
---|---|---|
committer | Mario de la Ossa <mariodelaossa@gmail.com> | 2019-06-18 16:57:37 -0600 |
commit | 39ec4d1c2824dafccc0d59bd0cfa3abce7d9154c (patch) | |
tree | adff30f2f21026e7c0bda3a9fd0381747a7fc7c2 | |
parent | ba952d53c5782e49b59ba3e5dd89c2c1eca02c80 (diff) | |
download | gitlab-ce-39ec4d1c2824dafccc0d59bd0cfa3abce7d9154c.tar.gz |
Backport of 12014-incremental-es-wiki-updatesce-12014-incremental-es-wiki-updates
Bringing in the DB migration and some light changes for CE classes
-rw-r--r-- | app/services/git/wiki_push_service.rb | 9 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 23 | ||||
-rw-r--r-- | db/migrate/20190607205656_add_wiki_columns_to_index_status.rb | 12 | ||||
-rw-r--r-- | db/schema.rb | 2 |
4 files changed, 38 insertions, 8 deletions
diff --git a/app/services/git/wiki_push_service.rb b/app/services/git/wiki_push_service.rb new file mode 100644 index 00000000000..a053f133016 --- /dev/null +++ b/app/services/git/wiki_push_service.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Git + class WikiPushService < ::BaseService + def execute + # This is used in EE + end + end +end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 3f1639ec2ed..dba7837bd12 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -30,15 +30,17 @@ class PostReceive private + def identify_user(post_received) + post_received.identify.tap do |user| + log("Triggered hook for non-existing user \"#{post_received.identifier}\"") unless user + end + end + def process_project_changes(post_received) changes = [] refs = Set.new - @user = post_received.identify - - unless @user - log("Triggered hook for non-existing user \"#{post_received.identifier}\"") - return false - end + user = identify_user(post_received) + return false unless user post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index| service_klass = @@ -51,7 +53,7 @@ class PostReceive if service_klass service_klass.new( post_received.project, - @user, + user, oldrev: oldrev, newrev: newrev, ref: ref, @@ -64,7 +66,7 @@ class PostReceive refs << ref end - after_project_changes_hooks(post_received, @user, refs.to_a, changes) + after_project_changes_hooks(post_received, user, refs.to_a, changes) end def after_project_changes_hooks(post_received, user, refs, changes) @@ -76,6 +78,11 @@ class PostReceive post_received.project.touch(:last_activity_at, :last_repository_updated_at) post_received.project.wiki.repository.expire_statistics_caches ProjectCacheWorker.perform_async(post_received.project.id, [], [:wiki_size]) + + user = identify_user(post_received) + return false unless user + + ::Git::WikiPushService.new(post_received.project, user, changes: post_received.enum_for(:changes_refs)).execute end def log(message) diff --git a/db/migrate/20190607205656_add_wiki_columns_to_index_status.rb b/db/migrate/20190607205656_add_wiki_columns_to_index_status.rb new file mode 100644 index 00000000000..0910d425212 --- /dev/null +++ b/db/migrate/20190607205656_add_wiki_columns_to_index_status.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddWikiColumnsToIndexStatus < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :index_statuses, :last_wiki_commit, :binary + add_column :index_statuses, :wiki_indexed_at, :datetime_with_timezone + end +end diff --git a/db/schema.rb b/db/schema.rb index a9643d70966..7a7319c132e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1572,6 +1572,8 @@ ActiveRecord::Schema.define(version: 20190613030606) do t.string "last_commit" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.binary "last_wiki_commit" + t.datetime_with_timezone "wiki_indexed_at" t.index ["project_id"], name: "index_index_statuses_on_project_id", unique: true, using: :btree end |