Skip to content
Snippets Groups Projects
Commit 28d89b79 authored by Steve Reis's avatar Steve Reis
Browse files

Merge branch 'feat/filter-and-formula' into 'develop'

Feature filter and formula

See merge request sibmip/gateway!62
parents 89aa7fda f7d14cb9
No related branches found
No related tags found
No related merge requests found
......@@ -221,6 +221,25 @@ export const dataToExperiment = (
.flat()
: [];
const allVariables = exp.filterVariables || [];
// add filter variables
const extractVariablesFromFilter = (filter: any): any =>
filter.rules.forEach((r: any) => {
if (r.rules) {
extractVariablesFromFilter(r);
}
if (r.id) {
allVariables.push(r.id);
}
});
if (exp && exp.filter) {
extractVariablesFromFilter(JSON.parse(exp.filter));
}
exp.filterVariables = Array.from(new Set(allVariables));
return exp;
} catch (e) {
return {
......
......@@ -23,6 +23,7 @@ import {
PartialExperiment,
} from 'src/engine/models/experiment/experiment.model';
import { ListExperiments } from 'src/engine/models/experiment/list-experiments.model';
import { FormulaOperation } from 'src/engine/models/formula/formula-operation.model';
import { Group } from 'src/engine/models/group.model';
import { Variable } from 'src/engine/models/variable.model';
import { ExperimentCreateInput } from 'src/experiments/models/input/experiment-create.input';
......@@ -52,6 +53,19 @@ export default class ExaremeService implements IEngineService {
private readonly httpService: HttpService,
) {}
async getFormulaConfiguration(): Promise<FormulaOperation[]> {
return [
{
variableType: 'real',
operationTypes: ['log', 'exp', 'center', 'standardize'],
},
{
variableType: 'nominal',
operationTypes: ['dummy', 'poly', 'contrast', 'additive'],
},
];
}
getConfiguration(): IConfiguration {
return {
contactLink: 'https://ebrains.eu/support/',
......
......@@ -13,6 +13,8 @@ import { ExperimentCreateInput } from '../experiments/models/input/experiment-cr
import { ExperimentEditInput } from '../experiments/models/input/experiment-edit.input';
import { ListExperiments } from './models/experiment/list-experiments.model';
import { ResultUnion } from './models/result/common/result-union.model';
import { FormulaOperation } from './models/formula/formula-operation.model';
import { FilterConfiguration } from './models/filter/filter-configuration';
export interface IEngineOptions {
type: string;
......@@ -122,6 +124,22 @@ export interface IEngineService {
data?: UpdateUserInput,
): Promise<User | undefined>;
/**
* This is a method that is used to get the list of formula operations
* that are available in the engine.
* @param req - Request - Optional request object from the HTTP request
* @returns - Formula configuration
*/
getFormulaConfiguration?(req?: Request): Promise<FormulaOperation[]>;
/**
* This is a method that is used to get the filter configuration
* that is available in the engine.
* @param req - Request - Optional request object from the HTTP request
* @returns Filter configuration
*/
getFilterConfiguration?(req?: Request): Promise<FilterConfiguration[]>;
/**
* Perform a logout on the current logged in user
* @param req - Request - this is the request object from the HTTP request.
......
......@@ -19,6 +19,8 @@ import { ErrorsInterceptor } from './interceptors/errors.interceptor';
import { Configuration } from './models/configuration.model';
import { Domain } from './models/domain.model';
import { Algorithm } from './models/experiment/algorithm.model';
import { FilterConfiguration } from './models/filter/filter-configuration';
import { FormulaOperation } from './models/formula/formula-operation.model';
@UseInterceptors(ErrorsInterceptor)
@UseGuards(GlobalAuthGuard)
......@@ -73,4 +75,20 @@ export class EngineResolver {
async algorithms(@GQLRequest() req: Request) {
return this.engineService.getAlgorithms(req);
}
@Query(() => [FormulaOperation])
async formula() {
if (this.engineService.getFormulaConfiguration)
return this.engineService.getFormulaConfiguration();
return [];
}
@Query(() => FilterConfiguration)
async filter() {
if (this.engineService.getFilterConfiguration)
return this.engineService.getFilterConfiguration();
return [];
}
}
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class FilterConfiguration {
@Field(() => [String], {
description: 'List of types that can considered as number',
defaultValue: ['real', 'integer'],
nullable: true,
})
numberTypes?: string[];
}
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class FormulaOperation {
@Field({ description: 'Type name of the variable' })
variableType: string;
@Field(() => [String], {
description: 'List of operation available for this type',
})
operationTypes: string[];
}
......@@ -158,6 +158,19 @@ type Algorithm {
description: String
}
type FilterConfiguration {
"""List of types that can considered as number"""
numberTypes: [String!]
}
type FormulaOperation {
"""Type name of the variable"""
variableType: String!
"""List of operation available for this type"""
operationTypes: [String!]!
}
type GroupResult {
name: String!
description: String
......@@ -358,6 +371,8 @@ type Query {
configuration: Configuration!
domains(ids: [String!] = []): [Domain!]!
algorithms: [Algorithm!]!
formula: [FormulaOperation!]!
filter: FilterConfiguration!
user: User!
experimentList(page: Float = 0, name: String = ""): ListExperiments!
experiment(id: String!): Experiment!
......
......@@ -20,6 +20,9 @@ export class UsersInterceptor implements NestInterceptor {
const ctx = GqlExecutionContext.create(context);
const req = ctx.getContext().req ?? ctx.switchToHttp().getRequest();
if (req.userExtended) return next.handle(); // user already extended
req.userExtended = true;
const user: User = req.user;
if (user && user.id) {
await this.usersService.extendedUser(user);
......
......@@ -60,7 +60,7 @@ export class UsersService {
} catch (err) {
if (err instanceof NotFoundException)
this.logger.debug(
`Extension of ${user.id} aborted, no user found in database`,
`Extension of ${user.id} not needed, user not found in database`,
);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment