mirror of
https://github.com/vale981/grapher
synced 2025-03-04 09:01:40 -05:00
Hotfixes 1.3.8
This commit is contained in:
parent
a4e1d45925
commit
7be6c2f1a6
6 changed files with 19 additions and 17 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.DS_Store
|
|
@ -11,6 +11,9 @@ export default (node, params) => {
|
|||
snapBackCaches(node);
|
||||
storeOneResults(node, node.results);
|
||||
|
||||
applyReducers(node, params);
|
||||
cleanReducerLeftovers(node);
|
||||
|
||||
_.each(node.collectionNodes, collectionNode => {
|
||||
cloneMetaChildren(collectionNode, node.results)
|
||||
});
|
||||
|
@ -19,9 +22,6 @@ export default (node, params) => {
|
|||
assembleMetadata(collectionNode, node.results)
|
||||
});
|
||||
|
||||
applyReducers(node, params);
|
||||
cleanReducerLeftovers(node);
|
||||
|
||||
removeLinkStorages(node, node.results);
|
||||
applyPostFilters(node);
|
||||
applyPostOptions(node);
|
||||
|
|
|
@ -28,6 +28,7 @@ export default function applyReducers(root, params) {
|
|||
root.results.forEach(result => {
|
||||
reducerNode.compute(result, params);
|
||||
});
|
||||
|
||||
processedReducers.push(reducerNode.name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export default function cleanReducerLeftovers(root) {
|
|||
// if profile will have empty keys, we need to delete profile.
|
||||
|
||||
/**
|
||||
*
|
||||
* Cleans what reducers needed to be computed and not used.
|
||||
* @param parts
|
||||
* @param results
|
||||
*/
|
||||
|
@ -44,12 +44,6 @@ function cleanNestedFields(parts, results, root) {
|
|||
const snapCacheField = root.snapCaches[parts[0]];
|
||||
const fieldName = snapCacheField ? snapCacheField : parts[0];
|
||||
|
||||
// We add this rule because if by any chance you use your reducer in conjunction with $options, $filters
|
||||
// They are removed from the body and will no longer be present.
|
||||
if (!root[fieldName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parts.length === 1) {
|
||||
results.forEach(result => {
|
||||
if (_.isObject(result) && fieldName !== '_id') {
|
||||
|
@ -61,7 +55,13 @@ function cleanNestedFields(parts, results, root) {
|
|||
}
|
||||
|
||||
parts.shift();
|
||||
cleanNestedFields(parts, results.map(result => result[fieldName]), root);
|
||||
cleanNestedFields(
|
||||
parts,
|
||||
results
|
||||
.filter(result => !!result[fieldName])
|
||||
.map(result => result[fieldName]),
|
||||
root
|
||||
);
|
||||
|
||||
results.forEach(result => {
|
||||
if (_.isObject(result[fieldName]) && _.keys(result[fieldName]).length === 0) {
|
||||
|
|
|
@ -24,7 +24,7 @@ export function handleAddElement(reducerNode, root, fieldName, body) {
|
|||
const collection = root.collection;
|
||||
const linker = collection.getLinker(fieldName);
|
||||
if (linker) {
|
||||
return handleAddLink(fieldName, body, root, linker);
|
||||
return handleAddLink(reducerNode, fieldName, body, root, linker);
|
||||
}
|
||||
|
||||
const reducer = collection.getReducer(fieldName);
|
||||
|
@ -60,11 +60,11 @@ export function handleAddReducer(fieldName, {body, reduce}, root) {
|
|||
* @param root
|
||||
* @param linker
|
||||
*/
|
||||
export function handleAddLink(fieldName, body, root, linker) {
|
||||
export function handleAddLink(reducerNode, fieldName, body, root, linker) {
|
||||
if (root.hasCollectionNode(fieldName)) {
|
||||
const collectionNode = root.getCollectionNode(fieldName);
|
||||
|
||||
embedReducerWithLink(body, collectionNode);
|
||||
embedReducerWithLink(reducerNode, body, collectionNode);
|
||||
} else {
|
||||
// add
|
||||
let collectionNode = new CollectionNode(linker.getLinkedCollection(), body, fieldName);
|
||||
|
|
|
@ -5,7 +5,7 @@ import {handleAddField, handleAddElement, handleAddReducer} from './createReduce
|
|||
* @param reducerBody
|
||||
* @param collectionNode
|
||||
*/
|
||||
export default function embedReducerWithLink(reducerBody, collectionNode) {
|
||||
export default function embedReducerWithLink(reducerNode, reducerBody, collectionNode) {
|
||||
_.each(reducerBody, (value, key) => {
|
||||
const collection = collectionNode.collection;
|
||||
|
||||
|
@ -25,14 +25,14 @@ export default function embedReducerWithLink(reducerBody, collectionNode) {
|
|||
}
|
||||
}
|
||||
|
||||
embedReducerWithLink(value, collectionNode.getCollectionNode(key));
|
||||
embedReducerWithLink(reducerNode, value, collectionNode.getCollectionNode(key));
|
||||
return;
|
||||
}
|
||||
|
||||
handleAddField(key, value, collectionNode);
|
||||
} else {
|
||||
// does not exist, so it may be a link/reducer/field
|
||||
handleAddElement(collectionNode, key, value);
|
||||
handleAddElement(reducerNode, collectionNode, key, value);
|
||||
}
|
||||
} else {
|
||||
// if this field or other reducer exists within the collection
|
||||
|
|
Loading…
Add table
Reference in a new issue