Commit 03370b01 authored by Valery Sizov's avatar Valery Sizov

ES: writing index status

parent a383f6ec
class IndexStatus < ActiveRecord::Base
belongs_to :project
end
......@@ -128,6 +128,7 @@ class Project < ActiveRecord::Base
has_one :custom_issue_tracker_service, dependent: :destroy
has_one :gitlab_issue_tracker_service, dependent: :destroy
has_one :external_wiki_service, dependent: :destroy
has_one :index_status, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_from_project, through: :forked_project_link
......
class CreateIndexStatuses < ActiveRecord::Migration
def change
create_table :index_statuses do |t|
t.integer :project_id
t.datetime :indexed_at
t.text :note
t.string :last_commit
t.timestamps null: false
end
add_index :index_statuses, :project_id
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160120172143) do
ActiveRecord::Schema.define(version: 20160129075828) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -414,6 +414,7 @@ ActiveRecord::Schema.define(version: 20160120172143) do
add_index "geo_nodes", ["host"], name: "index_geo_nodes_on_host", using: :btree
add_index "geo_nodes", ["primary"], name: "index_geo_nodes_on_primary", using: :btree
create_table "git_hooks", force: :cascade do |t|
t.string "force_push_regex"
t.string "delete_branch_regex"
......@@ -447,6 +448,17 @@ ActiveRecord::Schema.define(version: 20160120172143) do
add_index "identities", ["created_at", "id"], name: "index_identities_on_created_at_and_id", using: :btree
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
create_table "index_statuses", force: :cascade do |t|
t.integer "project_id"
t.datetime "indexed_at"
t.text "note"
t.string "last_commit"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "index_statuses", ["project_id"], name: "index_index_statuses_on_project_id", using: :btree
create_table "issues", force: :cascade do |t|
t.string "title"
t.integer "assignee_id"
......
......@@ -19,8 +19,15 @@ namespace :gitlab do
puts "Indexing #{project.name_with_namespace}..."
begin
# During indexing the new commits can be pushed,
# this parameter only indicates that at least this commit is in index
heeads_sha = project.repository.commit.sha
IndexStatus.find_or_create_by(last_commit: heeads_sha, project: project)
project.repository.index_commits
project.repository.index_blobs
project.index_status.update(indexed_at: DateTime.now)
puts "Done!".green
rescue StandardError => e
puts "#{e.message}, trace - #{e.backtrace}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment