From 87b6fff8218044b50dc216d2d5e3f9a55855e56e Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 20 Oct 2020 03:23:14 -0600 Subject: [PATCH] Corrected setup of `dbsize` for virtual assistants (#6270) * Corrected db size config for virtual assistants * Language fix, improvements, added dbsize to virtAsst config * Using env * Added logging * Debug logging * Different logging * More troubleshooting * Another try * Reverted stuff, added dbsize to server defaults * Fixed test * Fixed another test --- docs/plugins/alexa-templates/en-us.json | 10 ++++++++++ docs/plugins/google-home-templates/en-us.zip | Bin 6367 -> 6549 bytes lib/language.js | 2 +- lib/plugins/dbsize.js | 11 +++-------- lib/plugins/index.js | 1 + lib/plugins/virtAsstBase.js | 2 +- tests/dbsize.test.js | 11 +++-------- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/plugins/alexa-templates/en-us.json b/docs/plugins/alexa-templates/en-us.json index 79cc1baa977d..e890172dcbab 100644 --- a/docs/plugins/alexa-templates/en-us.json +++ b/docs/plugins/alexa-templates/en-us.json @@ -233,6 +233,16 @@ "name": { "value": "cgm mode" } + }, + { + "name": { + "value": "db size", + "synonyms": [ + "database size", + "data size", + "file size" + ] + } } ] } diff --git a/docs/plugins/google-home-templates/en-us.zip b/docs/plugins/google-home-templates/en-us.zip index d8ada2a834a29cb73802fb364902d86034ca3421..551e51307f05f5ce4ee9541928ff77bcf6516821 100644 GIT binary patch literal 6549 zcma)A1yoe+7NuK28ip36J0wI(K)PE%V#pZ~2I=mQZlp_6kZuWSgaHHzX%qxuK#&IC z;9LIi`^S4{)~vZ}-F5exbI;!AoNucsBBKx?U|?V%-~?!>Bisla`1Mm$b30QjAg3+F z!M^OXhMF3yA_wcp@Tg|Bh8pjCJ}95sN+~LWnj$(z{=HXj6!0g=;9s?W#KeN%h2z;f z|3s|Np0l45!uN*hqWHWr(@$nBbFj_Wp?KE=5Jip1!;oFmvs8{Vh}S43Iyow|fBmsQ z2Kg(Yf7sS_-#aaztTc zr!RI8*<%Xy)bKHY`wvtSO;sU3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kvsiUoYD4yyG(4;8f!ksBFEip zJ?fr`YXCJeOnxtX;ZKQBKEZUC+}5CxS1 z?XnKNJ^@AI0FaCf$PfN~cR3IJOYVPG zVt*bGT?e~9Vz>k|#kg{YD+7oBPmAAe{$HQpT2NzNZTkQH&aSupzoq_C;_elxzmwP> zh5*+Ux!!eN0um!n_4n-IfA*l);jTA)mvHlcfV=RQ>k!x5lS_z4NFVt7ME?-;A2F^M zlb0Ao1eX|pS786e?bnZVy@b1jTmA#wA5V0>-nfK#eB<&&e;e*k)yMTiT~Aq;h|$EC pi2uB&|Doh%SY40lOFTF-X0JxLHV^~pYybcu^4pD!or~5U@PCO>nezYu diff --git a/lib/language.js b/lib/language.js index ac9b0a022184..64098826fdea 100644 --- a/lib/language.js +++ b/lib/language.js @@ -15133,7 +15133,7 @@ function init() { ,nl: 'Datagrootte' }, 'virtAsstDatabaseSize': { - en: '%1 MiB that is %2% of available database space' + en: '%1 MiB. That is %2% of available database space.' ,pl: '%1 MiB co stanowi %2% przestrzeni dostępnej dla bazy danych' ,nl: '%1 MiB dat is %2% van de beschikbaare database ruimte' }, diff --git a/lib/plugins/dbsize.js b/lib/plugins/dbsize.js index c76e36cb9e85..1b6b43da8eda 100644 --- a/lib/plugins/dbsize.js +++ b/lib/plugins/dbsize.js @@ -119,9 +119,9 @@ function init (ctx) { function virtAsstDatabaseSizeHandler (next, slots, sbx) { var display = _.get(sbx, 'properties.dbsize.display'); - var dataSize = _.get(sbx, 'properties.dbsize.details.dataSize'); - var dataPercentage = _.get(sbx, 'properties.dbsize.dataPercentage'); if (display) { + var dataSize = _.get(sbx, 'properties.dbsize.details.dataSize'); + var dataPercentage = _.get(sbx, 'properties.dbsize.dataPercentage'); var response = translate('virtAsstDatabaseSize', { params: [ dataSize @@ -137,13 +137,8 @@ function init (ctx) { dbsize.virtAsst = { intentHandlers: [ { - // for backwards compatibility - intent: 'DatabaseSize' - , intentHandler: virtAsstDatabaseSizeHandler - } - , { intent: 'MetricNow' - , metrics: ['database size', 'file size', 'db size', 'data size'] + , metrics: ['db size'] , intentHandler: virtAsstDatabaseSizeHandler } ] diff --git a/lib/plugins/index.js b/lib/plugins/index.js index 5a6cb2822da3..77a87bcd94db 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -74,6 +74,7 @@ function init (ctx) { , require('./treatmentnotify')(ctx) , require('./timeago')(ctx) , require('./basalprofile')(ctx) + , require('./dbsize')(ctx) ]; plugins.registerServerDefaults = function registerServerDefaults () { diff --git a/lib/plugins/virtAsstBase.js b/lib/plugins/virtAsstBase.js index e0d103672a2e..781f56969cf1 100644 --- a/lib/plugins/virtAsstBase.js +++ b/lib/plugins/virtAsstBase.js @@ -81,7 +81,7 @@ function init(env, ctx) { }; virtAsstBase.setupVirtAsstHandlers = function (configuredPlugin) { - ctx.plugins.eachEnabledPlugin(function (plugin){ + ctx.plugins.eachEnabledPlugin(function (plugin) { if (plugin.virtAsst) { if (plugin.virtAsst.intentHandlers) { console.log('Plugin "' + plugin.name + '" supports Virtual Assistants'); diff --git a/tests/dbsize.test.js b/tests/dbsize.test.js index 0a66bb3ad6d7..ce95f8652c05 100644 --- a/tests/dbsize.test.js +++ b/tests/dbsize.test.js @@ -300,18 +300,13 @@ describe('Database Size', function() { var dbsize = require('../lib/plugins/dbsize')(ctx); dbsize.setProperties(sbx); - dbsize.virtAsst.intentHandlers.length.should.equal(2); + dbsize.virtAsst.intentHandlers.length.should.equal(1); dbsize.virtAsst.intentHandlers[0].intentHandler(function next (title, response) { title.should.equal('Database file size'); - response.should.equal('450 MiB that is 90% of available database space'); + response.should.equal('450 MiB. That is 90% of available database space.'); - dbsize.virtAsst.intentHandlers[1].intentHandler(function next (title, response) { - title.should.equal('Database file size'); - response.should.equal('450 MiB that is 90% of available database space'); - - done(); - }, [], sbx); + done(); }, [], sbx);