diff --git a/README.md b/README.md index 43eb21f..6c4969d 100644 --- a/README.md +++ b/README.md @@ -18,27 +18,6 @@ yarn // To get the dependencies installed yarn start // To start the server ``` -### Enable access to the Google status spreadsheet - -The [notes](http://localhost:3000/api/perf/notes) API requires a `GOOGLE_API_KEY` -in order to access a Google Spreadsheet. In order for this API to work locally -you need to create an API key for it. - -Follow these instructions - -* Visit [Google's cloud dashboard](https://console.cloud.google.com/apis/dashboard) -* Create a new project -* Select "Enable APIs and services" and enable "Google Sheets API" -* Back on the dashboard, go to credentials and create credentials - * Do not use the wizard but select "API Key" from the drop down -* Name it something recognizable like "fx health local server" -* Start the backend like this: - -``` -GOOGLE_API_KEY= yarn start -``` -* Visit http://localhost:3000/api/perf/notes to verify it works - ### Enable access to Nimbledroid's data Nimbledroid provides us with performance data for various sites on Android. If you want to make changes to the Nimbledroid APIs on the backend you will need diff --git a/package.json b/package.json index 6b34689..4b0ddd7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "dependencies": { "async-redis": "^1.1.4", "debug": "^4.1.1", - "googleapis": "^27.0.0", "isomorphic-fetch": "^2.2.1", "koa": "^2.3.0", "koa-compress": "^3.0.0", diff --git a/src/android/routes.js b/src/android/routes.js index 6776b0a..b4444fd 100644 --- a/src/android/routes.js +++ b/src/android/routes.js @@ -1,6 +1,5 @@ import Router from 'koa-router'; import queryNimbledroidData from '../utils/apis/queryNimbledroidData'; -import { getSpreadsheetValues } from '../utils/google'; import config from '../configuration'; const README_URL = `${config.repoUrl}/blob/master/README.md`; @@ -8,28 +7,6 @@ const README_URL = `${config.repoUrl}/blob/master/README.md`; export const router = new Router(); router - .get('/klar', async (ctx) => { - if (!process.env.GOOGLE_API_KEY) { - ctx.throw( - 500, - 'You need to set the GOOGLE_API_KEY for this endpoint to work. ' + - `More info in ${README_URL}`, - ); - } - const { site } = ctx.request.query; - if (!site) { - ctx.throw(400, 'You need to call this API by specifying a site parameter.'); - } - const list = await getSpreadsheetValues({ - id: config.androidSpreadsheetId, - range: site, - }); - list.forEach((entry) => { - entry.focus = parseFloat(entry.focus); - entry.klar = parseFloat(entry.klar); - }); - ctx.body = list; - }) .get('/nimbledroid', async (ctx) => { if (!process.env.NIMBLEDROID_API_KEY || !process.env.NIMBLEDROID_EMAIL) { ctx.throw( diff --git a/src/configuration.js b/src/configuration.js index 114bebd..64f3821 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -1,6 +1,4 @@ const config = { - quantumSpreadsheetId: '1UMsy_sZkdgtElr2buwRtABuyA3GY6wNK_pfF01c890A', - androidSpreadsheetId: '1vE0b3tawWY9vVNq9Ds6CiA9XZ6LStkcXZl3F8dwXid8', nimbledroidApiUrl: 'https://nimbledroid.com/api/v2/users/npark@mozilla.com/apps', repoUrl: 'https://github.com/mozilla/firefox-health-backend', }; diff --git a/src/perf.js b/src/perf.js index 7bc615f..1d43d97 100644 --- a/src/perf.js +++ b/src/perf.js @@ -5,8 +5,6 @@ import { median, quantile } from 'simple-statistics'; import { getLatestEvolution } from './perf/tmo'; import { fetchTelemetryEvolution } from './perf/tmo-wrapper'; import fetchJson from './fetch/json'; -import { getSpreadsheetValues } from './utils/google'; -import config from './configuration'; export const router = new Router(); @@ -23,34 +21,7 @@ const summarizeHistogram = (hist) => { }; }; -let notesCache = null; - router - .get('/notes', async (ctx) => { - if (process.env.GOOGLE_API_KEY) { - if (!notesCache) { - console.log('Fetching notes since it is not in the cache.'); - notesCache = (await getSpreadsheetValues({ - id: config.quantumSpreadsheetId, - range: 'Status!A1:F30', - })).reduce((hash, note) => { - hash[note.id] = note; - return hash; - }, {}); - - setTimeout(() => { - notesCache = null; - }, process.env.NODE_ENV === 'production' ? 1000 * 60 * 5 : 1000 * 60); - } - ctx.body = notesCache; - } else { - ctx.throw( - 400, - 'You need to set the GOOGLE_API_KEY for this endpoint to work. More info in ' + - `${config.repoUrl}/blob/master/README.md`, - ); - } - }) .get('/herder', async (ctx) => { const { framework } = ctx.request.query; let { signatures } = ctx.request.query; diff --git a/src/utils/google.js b/src/utils/google.js deleted file mode 100644 index b81742f..0000000 --- a/src/utils/google.js +++ /dev/null @@ -1,29 +0,0 @@ -import moment from 'moment'; -import fetchJson from '../fetch/json'; - -export const getSpreadsheetValues = async ({ id, range }) => { - const sheetsAPI = 'https://sheets.googleapis.com/v4/spreadsheets'; - const authKey = process.env.GOOGLE_API_KEY; - if (!authKey) { - console.error('The server was started without setting the GOOGLE_API_KEY'); - return []; - } - - const url = `${sheetsAPI}/${id}/values/${range}?key=${authKey}`; - const { values } = await fetchJson(url); - const headers = values.splice(0, 1).pop(); - - return values.reduce((criteria, entry) => { - const obj = {}; - headers.forEach((header, idx) => { - if (header.charAt(0) !== '_' && entry[idx]) { - obj[header] = entry[idx]; - if (header === 'date') { - obj[header] = moment(obj[header]).format('YYYY-MM-DD'); - } - } - }); - criteria.push(obj); - return criteria; - }, []); -}; diff --git a/test/android/klar.test.js b/test/android/klar.test.js deleted file mode 100644 index 925f34b..0000000 --- a/test/android/klar.test.js +++ /dev/null @@ -1,27 +0,0 @@ -/* global beforeEach, describe, it */ -import superagent from 'supertest'; -import app from '../../src/app'; - -const request = () => superagent(app.listen()); - -describe('/android', () => { - describe('GET /android/klar/', () => { - // The output in the test run is too noisy - // I don't want to spend more time on this as this is an API that - // will soon go away - it.skip('should return 500', (done) => { - delete process.env.GOOGLE_API_KEY; - request() - .get('/api/android/klar') - .expect(500, done); - }); - it('should return 400 due to not using ?site=', (done) => { - request() - .get('/api/android/klar') - .expect(400, done); - }); - beforeEach(() => { - process.env.GOOGLE_API_KEY = 'foo_bar'; - }); - }); -}); diff --git a/yarn.lock b/yarn.lock index 876baad..e2b2566 100644 --- a/yarn.lock +++ b/yarn.lock @@ -557,14 +557,6 @@ aws4@^1.6.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289" integrity sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w== -axios@^0.18.0: - version "0.18.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102" - integrity sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= - dependencies: - follow-redirects "^1.3.0" - is-buffer "^1.1.5" - babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -1323,11 +1315,6 @@ browserslist@^3.2.6: caniuse-lite "^1.0.30000844" electron-to-chromium "^1.3.47" -buffer-equal-constant-time@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" - integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= - buffer-from@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04" @@ -2294,13 +2281,6 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ecdsa-sig-formatter@1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz#1c595000f04a8897dfb85000892a0f4c33af86c3" - integrity sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM= - dependencies: - safe-buffer "^5.0.1" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -2795,7 +2775,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@^3.0.0, extend@^3.0.1, extend@~3.0.1: +extend@^3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" integrity sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ= @@ -3020,7 +3000,7 @@ fluture@^8.0.2: sanctuary-type-classes "^8.0.0" sanctuary-type-identifiers "^2.0.0" -follow-redirects@^1.0.0, follow-redirects@^1.3.0: +follow-redirects@^1.0.0: version "1.5.0" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.0.tgz#234f49cf770b7f35b40e790f636ceba0c3a0ab77" integrity sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA== @@ -3155,15 +3135,6 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -gcp-metadata@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/gcp-metadata/-/gcp-metadata-0.6.3.tgz#4550c08859c528b370459bd77a7187ea0bdbc4ab" - integrity sha512-MSmczZctbz91AxCvqp9GHBoZOSbJKAICV7Ow/AIWSJZRrRchUd5NL1b2P4OfP+4m490BEUPhhARfpHdqCxuCvg== - dependencies: - axios "^0.18.0" - extend "^3.0.1" - retry-axios "0.3.2" - get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" @@ -3281,38 +3252,6 @@ globby@^7.1.1: pify "^3.0.0" slash "^1.0.0" -google-auth-library@^1.3.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-1.6.1.tgz#9c73d831ad720c0c3048ab89d0ffdec714d07dd2" - integrity sha512-jYiWC8NA9n9OtQM7ANn0Tk464do9yhKEtaJ72pKcaBiEwn4LwcGYIYOfwtfsSm3aur/ed3tlSxbmg24IAT6gAg== - dependencies: - axios "^0.18.0" - gcp-metadata "^0.6.3" - gtoken "^2.3.0" - jws "^3.1.5" - lodash.isstring "^4.0.1" - lru-cache "^4.1.3" - retry-axios "^0.3.2" - -google-p12-pem@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/google-p12-pem/-/google-p12-pem-1.0.2.tgz#c8a3843504012283a0dbffc7430b7c753ecd4b07" - integrity sha512-+EuKr4CLlGsnXx4XIJIVkcKYrsa2xkAmCvxRhX2HsazJzUBAJ35wARGeApHUn4nNfPD03Vl057FskNr20VaCyg== - dependencies: - node-forge "^0.7.4" - pify "^3.0.0" - -googleapis@^27.0.0: - version "27.0.0" - resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-27.0.0.tgz#c210633b43e7047b65d33da40c489b6d8f9c02b8" - integrity sha512-Cz0BRsZmewc21N50x5nAUW5cqaGhJ9ETQKZMGqGL4BxmCV7ETELazSqmNi4oCDeRwM4Iub/fIJWAWZk2i6XLCg== - dependencies: - google-auth-library "^1.3.1" - pify "^3.0.0" - qs "^6.5.1" - string-template "1.0.0" - uuid "^3.2.1" - graceful-fs@^4.1.11, graceful-fs@^4.1.2: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -3328,17 +3267,6 @@ growl@1.10.3: resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== -gtoken@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-2.3.0.tgz#4e0ffc16432d7041a1b3dbc1d97aac17a5dc964a" - integrity sha512-Jc9/8mV630cZE9FC5tIlJCZNdUjwunvlwOtCz6IDlaiB4Sz68ki29a1+q97sWTnTYroiuF9B135rod9zrQdHLw== - dependencies: - axios "^0.18.0" - google-p12-pem "^1.0.0" - jws "^3.1.4" - mime "^2.2.0" - pify "^3.0.0" - handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" @@ -4250,23 +4178,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -jwa@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.1.6.tgz#87240e76c9808dbde18783cf2264ef4929ee50e6" - integrity sha512-tBO/cf++BUsJkYql/kBbJroKOgHWEigTKBAjjBEmrMGYd1QMBC74Hr4Wo2zCZw6ZrVhlJPvoMrkcOnlWR/DJfw== - dependencies: - buffer-equal-constant-time "1.0.1" - ecdsa-sig-formatter "1.0.10" - safe-buffer "^5.0.1" - -jws@^3.1.4, jws@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/jws/-/jws-3.1.5.tgz#80d12d05b293d1e841e7cb8b4e69e561adcf834f" - integrity sha512-GsCSexFADNQUr8T5HPJvayTjvPIfoyJPtLQBwn5a4WZQchcrPMPMAWcC1AzJVRDKyD6ZPROPAxgv6rfHViO4uQ== - dependencies: - jwa "^1.1.5" - safe-buffer "^5.0.1" - keygrip@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.2.tgz#ad3297c557069dea8bcfe7a4fa491b75c5ddeb91" @@ -4579,11 +4490,6 @@ lodash.debounce@^4.0.8: resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= - lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" @@ -4653,7 +4559,7 @@ lower-case@^1.1.0, lower-case@^1.1.1, lower-case@^1.1.2: resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw= -lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.3: +lru-cache@^4.0.1, lru-cache@^4.1.1: version "4.1.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" integrity sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA== @@ -4846,11 +4752,6 @@ mime@^1.4.1, mime@^1.5.0: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369" - integrity sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg== - mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -5096,7 +4997,7 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" -node-forge@0.7.5, node-forge@^0.7.4: +node-forge@0.7.5: version "0.7.5" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.7.5.tgz#6c152c345ce11c52f465c2abd957e8639cd674df" integrity sha512-MmbQJ2MTESTjt3Gi/3yG1wGpIMhUfcIypUCGtTizFR9IiccFwxSpfp0vtIZlkFclEqERemxfnSdZEMR9VqqEFQ== @@ -6255,11 +6156,6 @@ ret@~0.1.10: resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== -retry-axios@0.3.2, retry-axios@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/retry-axios/-/retry-axios-0.3.2.tgz#5757c80f585b4cc4c4986aa2ffd47a60c6d35e13" - integrity sha512-jp4YlI0qyDFfXiXGhkCOliBN1G7fRH03Nqy8YdShzGqbY5/9S2x/IR6C88ls2DFkbWuL3ASkP7QD3pVrNpPgwQ== - right-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" @@ -6835,11 +6731,6 @@ string-argv@^0.0.2: resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.0.2.tgz#dac30408690c21f3c3630a3ff3a05877bdcbd736" integrity sha1-2sMECGkMIfPDYwo/86BYd73L1zY= -string-template@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string-template/-/string-template-1.0.0.tgz#9e9f2233dc00f218718ec379a28a5673ecca8b96" - integrity sha1-np8iM9wA8hhxjsN5oopWc+zKi5Y= - string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -7332,7 +7223,7 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@^3.0.1, uuid@^3.1.0, uuid@^3.2.1: +uuid@^3.0.1, uuid@^3.1.0: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==