Skip to content

Commit

Permalink
add deactivation indexes, filter them out from indexing policy and ad…
Browse files Browse the repository at this point in the history
…apt previousely created models
  • Loading branch information
lenchvolodymyr committed Aug 6, 2021
1 parent bc8d884 commit 6bd7678
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 5 deletions.
63 changes: 63 additions & 0 deletions adapter/0.1.27.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright © 2016-2018 by IntegrIT S.A. dba Hackolade. All rights reserved.
*
* The copyright to the computer software herein is the property of IntegrIT S.A.
* The software may be used and/or copied only with the written permission of
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
* the agreement/contract under which the software has been supplied.
*
* {
* "add": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "remove": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "modify": {
* "entity": [
* {
* "from": { <properties that identify record> },
* "to": { <properties that need to be changed> }
* }
* ],
* "container": [],
* "model": [],
* "view": [],
* "field": []
* },
* }
*/
{
"add": {
"container": [
{
"path": ["includedPaths", "isActivated"],
"value": true
},
{
"path": ["excludedPaths", "isActivated"],
"value": true
},
{
"path": ["spatialIndexes", "isActivated"],
"value": true
},
{
"path": ["compositeIndexes", "isActivated"],
"value": true
}
]
}
}
14 changes: 10 additions & 4 deletions forward_engineering/helpers/getIndexPolicyScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const getPath = (paths = []) => {
}).concat(items[items.length - 1]).join('/');
};

const filterDeactivated = (items) => {
return (items || []).filter(item => {
return item.isActivated !== false;
});
};

const getIndex = (_) => (item) => {
const precision = Number(item.indexPrecision);
return _.flow(
Expand All @@ -67,23 +73,23 @@ const getIndex = (_) => (item) => {
};

const getIncludedPath = (_) => (includedPaths = []) => {
return includedPaths.map(item => {
return filterDeactivated(includedPaths).map(item => {
return _.flow(
add('path', getPath(item.indexIncludedPath)),
)({});
}).filter(item => !_.isEmpty(item));
};

const getExcludedPath = (_) => (excludedPaths = []) => {
return excludedPaths.map(item => {
return filterDeactivated(excludedPaths).map(item => {
return _.flow(
add('path', getPath(item.indexExcludedPath)),
)({});
}).filter(item => !_.isEmpty(item));
};

const getCompositeIndexes = (_) => (compositeIndexes = []) => {
return compositeIndexes.map(item => {
return filterDeactivated(compositeIndexes).map(item => {
if (!Array.isArray(item.compositeFieldPath)) {
return;
}
Expand All @@ -100,7 +106,7 @@ const getCompositeIndexes = (_) => (compositeIndexes = []) => {
};

const getSpatialIndexes = (_) => (spatialIndexes = []) => {
return spatialIndexes.map(item => {
return filterDeactivated(spatialIndexes).map(item => {
return _.flow(
add('path', getPath(item.indexIncludedPath)),
add('types', (item.dataTypes || []).map(dataType => dataType.spatialType).filter(Boolean)),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"versionDate": "2021-05-17",
"author": "hackolade",
"engines": {
"hackolade": "4.3.9",
"hackolade": "5.1.3",
"hackoladePlugin": "1.0.1"
},
"contributes": {
Expand Down
28 changes: 28 additions & 0 deletions properties_pane/container_level/containerLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ making sure that you maintain a proper JSON format.
"propertyTooltip": "",
"propertyType": "text"
},
{
"propertyName": "Activated",
"propertyKeyword": "isActivated",
"propertyTooltip": "Deactivated item will be not included in FE script",
"propertyType": "checkbox",
"defaultValue": true
},
{
"propertyName": "Path",
"propertyKeyword": "indexIncludedPath",
Expand Down Expand Up @@ -344,6 +351,13 @@ making sure that you maintain a proper JSON format.
"propertyTooltip": "",
"propertyType": "text"
},
{
"propertyName": "Activated",
"propertyKeyword": "isActivated",
"propertyTooltip": "Deactivated item will be not included in FE script",
"propertyType": "checkbox",
"defaultValue": true
},
{
"propertyName": "Path",
"propertyKeyword": "indexExcludedPath",
Expand Down Expand Up @@ -397,6 +411,13 @@ making sure that you maintain a proper JSON format.
"propertyTooltip": "",
"propertyType": "text"
},
{
"propertyName": "Activated",
"propertyKeyword": "isActivated",
"propertyTooltip": "Deactivated item will be not included in FE script",
"propertyType": "checkbox",
"defaultValue": true
},
{
"propertyName": "Path",
"propertyKeyword": "indexIncludedPath",
Expand Down Expand Up @@ -468,6 +489,13 @@ making sure that you maintain a proper JSON format.
"propertyTooltip": "",
"propertyType": "text"
},
{
"propertyName": "Activated",
"propertyKeyword": "isActivated",
"propertyTooltip": "Deactivated item will be not included in FE script",
"propertyType": "checkbox",
"defaultValue": true
},
{
"propertyName": "Path",
"propertyKeyword": "compositeFieldPath",
Expand Down

0 comments on commit 6bd7678

Please sign in to comment.