Преглед на файлове

👽️ align clusters calculation with API changes

...enforced by the ontology integration
jmacura преди 4 години
родител
ревизия
bd8c1af553
променени са 1 файла, в които са добавени 17 реда и са изтрити 9 реда
  1. 17 9
      src/adjuster/adjuster.service.ts

+ 17 - 9
src/adjuster/adjuster.service.ts

@@ -173,18 +173,26 @@ export class AdjusterService {
 
   calculateClusters(): void {
     this._clusteringInProcess = true;
+    /* Pre-process the API params */
+    const params = [];
+    for (const factor of this.factors) {
+      for (const dataset of factor.datasets) {
+        if (!dataset.included) {
+          continue;
+        }
+        const flattenedDataset = {
+          id: dataset.id.split('/').slice(-1).pop(), //We do not need full URIs as the URNs are unique across the ontology
+          factor: factor.id.split('/').slice(-1).pop(), //We do not need full URIs as the URNs are unique across the ontology
+          weight: factor.weight
+        };
+        params.push(flattenedDataset)
+      }
+    }
+
     this.$http
       .post(this.serviceBaseUrl + 'cz/clusters/', {
         numberOfClusters: this.numberOfClusters,
-        factors: this.factors.map((f) => {
-          return {
-            factor: f.name,
-            weight: f.weight,
-            datasets: f.datasets
-              .filter((ds) => ds.included)
-              .map((ds) => ds.name),
-          };
-        }),
+        datasets: params
       })
       .toPromise()
       .then((data: any) => {