Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left links overriding only for blocks of added or changed library versions #36

Merged
merged 2 commits into from
Jul 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/tasks/override-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,33 @@ module.exports = function (target) {
return vow.resolve(target);
}

var languages = utility.getLanguages();
var languages = utility.getLanguages(),
librariesChanges = target.getChanges().getLibraries(),
changedLibVersions = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changedLibVersions = [].concat(target.getChanges().getLibraries().getAdded(), target.getChanges().getLibraries().getModified())

или здесь ради красоты 2 раза concat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, для красоты

.concat(librariesChanges.getAdded())
.concat(librariesChanges.getModified());

/**
* Decides that given nodeValue is needed for override links
* @param {Object} nodeValue
* @returns {boolean} flag which indicates that it is important to rescan given source
* and override or re-override links in it
*/
function isNeedToOverride(nodeValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Какого-нибудь бы сюда jsdoc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

неважно

var route = nodeValue.route,
conditions,
lib,
version;

conditions = route.conditions;
lib = conditions.lib;
version = conditions.version;

return changedLibVersions.some(function (item) {
return item.lib === lib && item.version === version;
});
}

return vow.all([
levelDb.get().getByKeyRange(target.KEY.NODE_PREFIX, target.KEY.PEOPLE_PREFIX),
collectUrls(target)
Expand All @@ -338,6 +364,10 @@ module.exports = function (target) {
var nodeValue = nodeRecord.value;

if (nodeValue.source && nodeValue.source.data) {
if(!isNeedToOverride(nodeValue)) {
return vow.resolve();
}

return levelDb.get().get(nodeValue.source.data).then(function (blockValue) {
if (!blockValue) {
return vow.resolve();
Expand Down