From 46aa7d1216706dfeece085344e6b3de3ba53b08b Mon Sep 17 00:00:00 2001
From: stevereis <stevereis93@gmail.com>
Date: Mon, 17 Jan 2022 17:58:36 +0100
Subject: [PATCH] feat: Add formula into experiment model

---
 .../models/experiment/experiment.model.ts     | 21 +++++++++++++++++++
 api/src/schema.gql                            | 17 ++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/api/src/engine/models/experiment/experiment.model.ts b/api/src/engine/models/experiment/experiment.model.ts
index 7f2d51e..eb757d6 100644
--- a/api/src/engine/models/experiment/experiment.model.ts
+++ b/api/src/engine/models/experiment/experiment.model.ts
@@ -3,6 +3,24 @@ import { ResultUnion } from '../result/common/result-union.model';
 import { Algorithm } from './algorithm.model';
 import { Author } from './author.model';
 
+@ObjectType()
+export class Transformation {
+  @Field({ description: "Variable's id on which to apply the transformation" })
+  id: string;
+
+  @Field({ description: 'Transformation to apply' })
+  operation: string;
+}
+
+@ObjectType()
+export class Formula {
+  @Field(() => [Transformation], { nullable: true, defaultValue: [] })
+  transformations: Transformation[];
+
+  @Field(() => [[String]], { nullable: true, defaultValue: [] })
+  interactions: string[][];
+}
+
 @ObjectType()
 export class Experiment {
   @Field()
@@ -53,6 +71,9 @@ export class Experiment {
   @Field(() => [String], { nullable: true, defaultValue: [] })
   filterVariables?: string[];
 
+  @Field(() => Formula, { nullable: true })
+  formula?: Formula;
+
   @Field()
   algorithm: Algorithm;
 }
diff --git a/api/src/schema.gql b/api/src/schema.gql
index 7e173ad..feb05a8 100644
--- a/api/src/schema.gql
+++ b/api/src/schema.gql
@@ -137,6 +137,19 @@ type Author {
   fullname: String
 }
 
+type Transformation {
+  """Variable's id on which to apply the transformation"""
+  id: String!
+
+  """Transformation to apply"""
+  operation: String!
+}
+
+type Formula {
+  transformations: [Transformation!]
+  interactions: [[String!]!]
+}
+
 type Experiment {
   id: String!
   name: String!
@@ -154,6 +167,7 @@ type Experiment {
   variables: [String!]!
   coVariables: [String!]
   filterVariables: [String!]
+  formula: Formula
   algorithm: Algorithm!
 }
 
@@ -174,6 +188,7 @@ type PartialExperiment {
   variables: [String!]
   coVariables: [String!]
   filterVariables: [String!]
+  formula: Formula
   algorithm: Algorithm
 }
 
@@ -227,7 +242,7 @@ enum ParamType {
 }
 
 input FormulaTransformation {
-  name: String!
+  id: String!
   operation: String!
 }
 
-- 
GitLab