Drop old Nimbledroid code & remove versioning of API

When we released version 3 of the API we left around the old code.

In the future try not to add different versions of the APIs if you
don't need to support multiple versions of the API at the same time.
This commit is contained in:
Armen Zambrano G 2019-03-12 12:12:46 -04:00
Родитель 942c680778
Коммит 58b39fdf51
2 изменённых файлов: 4 добавлений и 22 удалений

Просмотреть файл

@ -58,7 +58,7 @@ DEBUG=script:info,script:error yarn fetchNimbledroidData
yarn start
```
Load [this page](http://localhost:3000/api/nimbledroid?product=focus) to verify it works.
Load [this page](http://localhost:3000/api/android/nimbledroid?product=com.chrome.beta) to verify it works.
### Redis

Просмотреть файл

@ -19,7 +19,7 @@ const latest = (a, b) => {
return latestVersion;
};
const moreData = (data, packageId) => {
const processedData = (data, packageId) => {
let latestVersion = ['0', '0', '0', '0'];
const scenarios = {};
// eslint-disable-next-line camelcase
@ -45,32 +45,14 @@ const moreData = (data, packageId) => {
};
};
const optimizedData = (data, packageId) => {
const newData = {};
data.forEach(({ added, profiles }) => {
// eslint-disable-next-line camelcase
profiles.forEach(({ scenario_name, time_in_ms }) => {
if (!newData[scenario_name]) {
newData[scenario_name] = [];
}
newData[scenario_name].push({
date: added,
ms: time_in_ms,
});
});
});
return { [packageId]: newData };
};
const queryNimbledroidData = async (product, version) => {
const queryNimbledroidData = async (product) => {
const cachedKeys = await client.keys(`cache:*nimble*${product}/apks/*`);
const data = await Promise.all(cachedKeys.map(async key =>
JSON.parse(await client.get(key))));
if (data.length === 0) {
throw Error('The script that fetches data should have run before hitting the API.');
}
// Drop support for version 1
return version === '3' ? moreData(data, product) : optimizedData(data, product);
return processedData(data, product);
};
export default queryNimbledroidData;