Skip to content

Commit

Permalink
Merge pull request #810 from opentable/async-update
Browse files Browse the repository at this point in the history
[DX-270] Async update
  • Loading branch information
nickbalestra authored Jan 23, 2018
2 parents 6567484 + 3d45aa9 commit ff8193a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"dependencies": {
"accept-language-parser": "1.4.1",
"async": "1.5.2",
"async": "^2.6.0",
"basic-auth-connect": "^1.0.0",
"body-parser": "1.18.2",
"builtin-modules": "^2.0.0",
Expand Down
53 changes: 26 additions & 27 deletions src/registry/domain/components-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,34 @@ module.exports = (conf, cdn) => {
const details = _.extend({}, _.cloneDeep(options.details));
details.components = details.components || {};

async.eachOfSeries(
options.componentsList.components,
(versions, name, done) => {
details.components[name] = details.components[name] || {};
const missing = [];
_.each(options.componentsList.components, (versions, name) => {
details.components[name] = details.components[name] || {};
_.each(versions, version => {
if (!details.components[name][version]) {
missing.push({ name, version });
}
});
});

async.eachLimit(
versions,
cdn.maxConcurrentRequests,
(version, next) => {
if (details.components[name][version]) {
next();
} else {
cdn.getJson(
`${conf.storage.options
.componentsDir}/${name}/${version}/package.json`,
true,
(err, content) => {
if (err) {
return next(err);
}
details.components[name][version] = {
publishDate: content.oc.date || 0
};
next();
}
);
async.eachLimit(
missing,
cdn.maxConcurrentRequests,
({ name, version }, next) => {
cdn.getJson(
`${conf.storage.options.componentsDir}/${name}/${
version
}/package.json`,
true,
(err, content) => {
if (err) {
return next(err);
}
},
done
details.components[name][version] = {
publishDate: content.oc.date || 0
};
next();
}
);
},
err =>
Expand Down

0 comments on commit ff8193a

Please sign in to comment.