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

Merge branch...

Merge branch '29-as-a-client-i-want-to-consume-the-result-of-the-descriptive-statistics-algorithm-so-i-can-render' into 31-as-a-client-i-want-to-be-able-to-query-specific-fields-in-experiment-result-api-so-that-i-only
parents 6089411b b81a2428
No related branches found
No related tags found
No related merge requests found
// This file contains all transformation queries for JSONata
// see : https://docs.jsonata.org/
import * as jsonata from 'jsonata'; // old import style needed because of 'export = jsonata'
import * as jsonata from 'jsonata'; // old import style needed due to 'export = jsonata'
export const transientToTable = jsonata(`
(
$e := function($x) {($x != null) ? $x : ''};
$e := function($x, $r) {($x != null) ? $x : ($r ? $r : '')};
$fn := function($o, $prefix) {
$each($o, function($v, $k) {(
$name := $join([$prefix,$k], '/');
$type($v) = 'object' ? $fn($v, $name): {
$name: $v
}
)}) ~> $merge()
};
$fn := function($o, $prefix) {
$type($o) = 'object' ?
$each($o, function($v, $k) {(
$type($v) = 'object' ? { $k: $v.count & ' (' & $v.percentage & '%)' } : {
$k: $v
}
)}) ~> $merge()
: {}
};
result.data.[
$.single.*@$p#$i.{
'groupBy' : 'single',
'name': $keys(%)[$i],
'metadatas': $append("", $keys(*)).{
'name': $,
'type': 'string'
},
'data' : [
[$keys(%)[$i], $p.*.($e(num_total))],
['Datapoints', $p.*.($e(num_datapoints))],
['Nulls', $p.*.($e(num_nulls))],
$p.*.data.($fn($)) ~> $reduce(function($a, $b) {
$each($a, function($v, $k) {(
{
$k : [$v, $e($lookup($b,$k))]
}
)}) ~> $merge()
}) ~> $each(function($v, $k) {$append($k,$v)})
]
}
]
result.data.[
$.single.*@$p#$i.(
$ks := $keys($p.*.data[$type($) = 'object']);
{
'groupBy' : 'single',
'name': $keys(%)[$i],
'headers': $append("", $keys(*)).{
'name': $,
'type': 'string'
},
'data' : [
[$keys(%)[$i], $p.*.($e(num_total))],
['Datapoints', $p.*.($e(num_datapoints))],
['Nulls', $p.*.($e(num_nulls))],
$p.*.data.($fn($)) ~> $reduce(function($a, $b) {
$map($ks, function($k) {(
{
$k : [$e($lookup($a,$k), "No data"), $e($lookup($b,$k), "No data")]
}
)}) ~> $merge()
}) ~> $each(function($v, $k) {$append($k,$v)})
]
})
]
)
`);
......@@ -11,7 +11,7 @@ export const ResultUnion = createUnionType({
name: 'ResultUnion',
types: () => [TableResult, DummyResult],
resolveType(value) {
if (value.metadatas) {
if (value.headers) {
return TableResult;
}
if (value.listMax) {
......
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class Metadata {
export class Header {
@Field()
name: string;
......
import { Field, ObjectType } from '@nestjs/graphql';
import { Metadata } from './common/metadata.model';
import { Header } from './common/header.model';
import { Result } from './common/result.model';
@ObjectType()
......@@ -10,6 +10,6 @@ export class TableResult extends Result {
@Field(() => [[String]])
data: string[][];
@Field(() => [Metadata])
metadatas: Metadata[];
@Field(() => [Header])
headers: Header[];
}
......@@ -34,7 +34,7 @@ type Domain {
rootGroup: Group!
}
type Metadata {
type Header {
name: String!
type: String!
}
......@@ -59,7 +59,7 @@ type TableResult {
groupBy: String
name: String!
data: [[String!]!]!
metadatas: [Metadata!]!
headers: [Header!]!
}
type DummyResult {
......
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