* Fix #71 - Fetch Nimbledroid data from nimbledroid-admin user * Handle Profiled status and empty data Until now, all profiled results from Nimbledroid had a status of `Failure`. It seems they fixed the bug and we now have the `Profiled` status being used. I've noticed that some of the end points return empty data and we now handle it.
This commit is contained in:
Родитель
cbde0b44c3
Коммит
5455a5d52d
|
@ -1,5 +1,5 @@
|
||||||
const config = {
|
const config = {
|
||||||
nimbledroidApiUrl: 'https://nimbledroid.com/api/v2/users/npark@mozilla.com/apps',
|
nimbledroidApiUrl: 'https://nimbledroid.com/api/v2/users/nimbledroid-admin@mozilla.com/apps',
|
||||||
repoUrl: 'https://github.com/mozilla/firefox-health-backend',
|
repoUrl: 'https://github.com/mozilla/firefox-health-backend',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ const storeProfilingRunIfMissing = async (profilingRunData) => {
|
||||||
// e.g. cache:https://nimbledroid.com/api/v2/users/npark@mozilla.com/apps/org.mozilla.klar/apks/103
|
// e.g. cache:https://nimbledroid.com/api/v2/users/npark@mozilla.com/apps/org.mozilla.klar/apks/103
|
||||||
const key = `cache:${url}`;
|
const key = `cache:${url}`;
|
||||||
// The status 'Failed' means 'completed' in the Nimbledroid API
|
// The status 'Failed' means 'completed' in the Nimbledroid API
|
||||||
if (status === 'Failed') {
|
if (status === 'Failed' || status === 'Profiled') {
|
||||||
const cached = await redisClient.get(key);
|
const cached = await redisClient.get(key);
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
debugLog(`Storing ${key}`);
|
debugLog(`Storing ${key}`);
|
||||||
|
@ -66,8 +66,10 @@ const main = async () => {
|
||||||
].map(async (productName) => {
|
].map(async (productName) => {
|
||||||
infoLog(`Fetching ${productName}`);
|
infoLog(`Fetching ${productName}`);
|
||||||
const productData = await fetchData(productName);
|
const productData = await fetchData(productName);
|
||||||
infoLog(`Storing ${productName}`);
|
if (productData.length > 0) {
|
||||||
await storeDataInRedis(productData);
|
infoLog(`Storing ${productName}`);
|
||||||
|
await storeDataInRedis(productData);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
errorCode = 0;
|
errorCode = 0;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
import debug from 'debug';
|
||||||
import fetchJson from '../../fetch/json';
|
import fetchJson from '../../fetch/json';
|
||||||
import config from '../../configuration';
|
import config from '../../configuration';
|
||||||
|
|
||||||
|
const errorLog = debug('script:error');
|
||||||
|
|
||||||
const apiUrl = product => `${config.nimbledroidApiUrl}/${product}/apks`;
|
const apiUrl = product => `${config.nimbledroidApiUrl}/${product}/apks`;
|
||||||
|
|
||||||
const generateAuthKey = (email, apiKey) => (
|
const generateAuthKey = (email, apiKey) => (
|
||||||
|
@ -29,7 +32,8 @@ class NimbledroidHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchData(product) {
|
async fetchData(product) {
|
||||||
return fetchJson(
|
const url = apiUrl(product);
|
||||||
|
const data = await fetchJson(
|
||||||
apiUrl(product),
|
apiUrl(product),
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -37,6 +41,10 @@ class NimbledroidHandler {
|
||||||
ttl: 30 * 60, // 30 minutes
|
ttl: 30 * 60, // 30 minutes
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
if (data.length === 0) {
|
||||||
|
errorLog(`There was nothing to be stored from ${url}`);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateAuthHeaders() {
|
generateAuthHeaders() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче