Skip to content

Commit

Permalink
chore(elasticsearch): indexName
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed May 23, 2019
1 parent e320e83 commit 1b4d699
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var moment = require('moment-timezone')
var settingUtil = require('../settings/settingsUtil')

var ES = {}
ES.indexName = process.env.ELASTICSEARCH_INDEX_NAME || 'trudesk'

function checkConnection (callback) {
if (!ES.esclient) return callback('Elasticsearch client not initialized. Restart Trudesk!')
Expand All @@ -40,7 +41,7 @@ function checkConnection (callback) {
}

ES.testConnection = function (callback) {
if (process.env.ELATICSEARCH_URI) ES.host = process.env.ELATICSEARCH_URI
if (process.env.ELEASTICSEARCH_URI) ES.host = process.env.ELEASTICSEARCH_URI
else ES.host = nconf.get('elasticsearch:host') + ':' + nconf.get('elasticsearch:port')

ES.esclient = new elasticsearch.Client({
Expand All @@ -57,7 +58,7 @@ ES.setupHooks = function () {

ES.esclient.index(
{
index: 'trudesk',
index: ES.indexName,
type: 'ticket',
id: data._id.toString(),
refresh: 'true',
Expand Down Expand Up @@ -103,7 +104,7 @@ ES.setupHooks = function () {

ES.esclient.index(
{
index: 'trudesk',
index: ES.indexName,
type: 'doc',
id: ticket._id.toString(),
refresh: 'true',
Expand Down Expand Up @@ -154,7 +155,7 @@ ES.setupHooks = function () {

ES.esclient.index(
{
index: 'trudesk',
index: ES.indexName,
type: 'doc',
id: _id,
body: cleanedTicket
Expand Down Expand Up @@ -226,7 +227,7 @@ ES.getIndexCount = function (callback) {

ES.esclient.count(
{
index: 'trudesk'
index: ES.indexName
},
callback
)
Expand Down
4 changes: 2 additions & 2 deletions src/migration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getDatabaseVersion (callback) {
SettingsSchema.getSettingByName('gen:version', function (err, setting) {
if (err) return callback(err)

if (!setting) throw new Error('Please upgrade to v1.0.7+ Exiting...')
if (!setting) throw new Error('Please upgrade to v1.0.7 Exiting...')

return callback(null, setting.value)
})
Expand Down Expand Up @@ -207,7 +207,7 @@ migrations.run = function (callback) {
databaseVersion = dbVer

if (semver.satisfies(databaseVersion, '<1.0.10')) {
throw new Error('Please upgrade to v1.0.10+ Exiting...')
throw new Error('Please upgrade to v1.0.10 Exiting...')
}
return next()
})
Expand Down

0 comments on commit 1b4d699

Please sign in to comment.