fixed
This commit is contained in:
parent
e1d1b99ae9
commit
b09968684f
@ -14,24 +14,13 @@ module Devops
|
|||||||
mongo_user = config[:mongo_user]
|
mongo_user = config[:mongo_user]
|
||||||
mongo_password = config[:mongo_password]
|
mongo_password = config[:mongo_password]
|
||||||
@@db = MongoConnector.new(mongo_db, mongo_host, mongo_port, mongo_user, mongo_password)
|
@@db = MongoConnector.new(mongo_db, mongo_host, mongo_port, mongo_user, mongo_password)
|
||||||
create_indexes
|
@@db.create_indexes
|
||||||
end
|
end
|
||||||
|
|
||||||
def connector
|
def connector
|
||||||
@@db
|
@@db
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_indexes
|
|
||||||
reports_coll = @@db.reports_connector
|
|
||||||
info = reports_coll.index_information
|
|
||||||
unless info["created_at_1"]
|
|
||||||
reports_coll.create_index({created_at: Mongo::ASCENDING})
|
|
||||||
end
|
|
||||||
unless info["project_1_deploy_env_1_created_at_1"]
|
|
||||||
reports_coll.create_index({project: Mongo::ASCENDING, deploy_env: Mongo::ASCENDING, created_at: Mongo::ASCENDING})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,6 +5,11 @@ require "exceptions/invalid_privileges"
|
|||||||
|
|
||||||
module Connectors
|
module Connectors
|
||||||
class Base
|
class Base
|
||||||
|
|
||||||
|
def create_indexes
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# Yes, we can implement connectors without attr_accessor, storing collection directly
|
# Yes, we can implement connectors without attr_accessor, storing collection directly
|
||||||
# in instance variable like
|
# in instance variable like
|
||||||
# @collection = db.collection('users')
|
# @collection = db.collection('users')
|
||||||
|
|||||||
@ -51,6 +51,16 @@ module Connectors
|
|||||||
collection.update({"_id" => id}, {"$set" => {"chef_node_name" => chef_node_name, "host" => host}})
|
collection.update({"_id" => id}, {"$set" => {"chef_node_name" => chef_node_name, "host" => host}})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_indexes
|
||||||
|
info = self.collection.index_information
|
||||||
|
unless info["created_at_1"]
|
||||||
|
self.collection.create_index({created_at: Mongo::ASCENDING})
|
||||||
|
end
|
||||||
|
unless info["project_1_deploy_env_1_created_at_1"]
|
||||||
|
self.collection.create_index({project: Mongo::ASCENDING, deploy_env: Mongo::ASCENDING, created_at: Mongo::ASCENDING})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def model_from_bson(bson)
|
def model_from_bson(bson)
|
||||||
|
|||||||
@ -39,6 +39,10 @@ class MongoConnector
|
|||||||
@db.authenticate(user, password) unless user.nil? or password.nil?
|
@db.authenticate(user, password) unless user.nil? or password.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_indexes
|
||||||
|
reports_connector.create_indexes
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def images_connector
|
def images_connector
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user