Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selectedFilters.forEach((filter: Filter) => {
if ((filter.operator === ConseilOperator.BETWEEN || filter.operator === ConseilOperator.IN || filter.operator === 'notin') && filter.values.length === 1) {
return true;
}
if (filter.operator !== ConseilOperator.ISNULL && filter.operator !== 'isnotnull' && (filter.values.length === 0 || filter.values[0].length === 0)) {
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
} else {
query = addPredicate(query, filter.name, operator, filter.values, isInvert);
filters = predicates.map(predicate => {
const selectedAttribute = attributes.find(attr => attr.name === predicate.field);
const isLowCardinality = selectedAttribute.cardinality !== undefined && selectedAttribute.cardinality < CARDINALITY_NUMBER;
if (isLowCardinality) {
cardinalityPromises.push(
dispatch(initCardinalityValues(platform, entity, network, selectedAttribute.name, serverInfo))
);
}
const operatorType = getOperatorType(selectedAttribute.dataType);
let operator = predicate.operation;
if (predicate.inverse) {
if (predicate.operation === ConseilOperator.ISNULL) {
operator = 'isnotnull';
} else if (predicate.operation === ConseilOperator.EQ) {
operator = 'noteq';
} else if (predicate.operation === ConseilOperator.STARTSWITH) {
operator = 'notstartWith';
} else if (predicate.operation === ConseilOperator.ENDSWITH) {
operator = 'notendWith';
} else if (predicate.operation === ConseilOperator.IN) {
operator = 'notin';
}
}
return {
name: predicate.field,
operator,
values: predicate.set,
operatorType,
isLowCardinality
const initFilters = predicates.map(predicate => {
const selectedAttribute = attributes[entity].find(attr => attr.name === predicate.field);
const isLowCardinality = selectedAttribute.cardinality !== undefined && selectedAttribute.cardinality < CARDINALITY_NUMBER;
if (isLowCardinality) {
cardinalityPromises.push(
dispatch(initCardinalityValues(platform, entity, network, selectedAttribute.name, serverInfo))
);
}
const operatorType = getOperatorType(selectedAttribute.dataType);
let operator = predicate.operation;
if (predicate.inverse) {
if (predicate.operation === ConseilOperator.ISNULL) {
operator = 'isnotnull';
} else if (predicate.operation === ConseilOperator.EQ) {
operator = 'noteq';
} else if (predicate.operation === ConseilOperator.STARTSWITH) {
operator = 'notstartWith';
} else if (predicate.operation === ConseilOperator.ENDSWITH) {
operator = 'notendWith';
} else if (predicate.operation === ConseilOperator.IN) {
operator = 'notin';
}
}
return {
name: predicate.field,
operator,
values: predicate.set,
operatorType,
isLowCardinality
...defaultQuery,
predicates: [{ field: 'block_hash', set: [hash], operation: ConseilOperator.EQ, inverse: false }]
};
const serverInfo = { url, apiKey, network };
let columns: any[] = [];
const { fields, predicates, orderBy } = defaultQuery;
fields.forEach(field=> {
const column = attributes[entity].find(attr => attr.name === field);
if (column) { columns.push(column); }
});
const sorts: any = orderBy.map(o => { return { orderBy: o.field, order: o.direction } });
const mainFilters = [{
name: 'block_hash',
operator: ConseilOperator.EQ,
operatorType: 'string',
isLowCardinality: false,
values: [hash]
}];
if(!items[entity] || (items[entity] && items[entity].length === 0)) {
let cardinalityPromises: any[] = [];
const initFilters = predicates.map(predicate => {
const selectedAttribute = attributes[entity].find(attr => attr.name === predicate.field);
const isLowCardinality = selectedAttribute.cardinality !== undefined && selectedAttribute.cardinality < CARDINALITY_NUMBER;
if (isLowCardinality) {
cardinalityPromises.push(
dispatch(initCardinalityValues(platform, entity, network, selectedAttribute.name, serverInfo))
);
}
const operatorType = getOperatorType(selectedAttribute.dataType);
export const gotoOperationsForBlockThunk = (hash: string) => async (dispatch: any, state: any) => {
dispatch(setLoadingAction(true));
const { selectedConfig, attributes, items } = state().app;
const { platform, network, url, apiKey } = selectedConfig;
const entity = 'operations';
const defaultQuery = {...ConseilQueryBuilder.blankQuery(), ...defaultQueries[entity]};
const mainQuery: any = {
...defaultQuery,
predicates: [{ field: 'block_hash', set: [hash], operation: ConseilOperator.EQ, inverse: false }]
};
const serverInfo = { url, apiKey, network };
let columns: any[] = [];
const { fields, predicates, orderBy } = defaultQuery;
fields.forEach(field=> {
const column = attributes[entity].find(attr => attr.name === field);
if (column) { columns.push(column); }
});
const sorts: any = orderBy.map(o => { return { orderBy: o.field, order: o.direction } });
const mainFilters = [{
name: 'block_hash',
operator: ConseilOperator.EQ,
operatorType: 'string',
isLowCardinality: false,