Skip to content

Commit

Permalink
Merge branch 'develop' into feature/parallel-startup
Browse files Browse the repository at this point in the history
  • Loading branch information
awildturtok authored Jun 30, 2020
2 parents c554f45 + 21f29ee commit 0be8f1b
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import com.bakdata.conquery.models.identifiable.ids.specific.UserId;
import com.bakdata.conquery.models.query.ColumnDescriptor;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -23,6 +24,7 @@ public class ExecutionStatus {

private String[] tags;
private String label;
@JsonProperty("isPristineLabel")
private boolean isPristineLabel;
private ZonedDateTime createdAt;
private ZonedDateTime lastUsed;
Expand Down
36 changes: 18 additions & 18 deletions docs/REST API JSONs.md
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ Supported Fields:
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/config/FrontendConfig.java#L24) | thousandSeparator | `String` | `"."` | | |
</p></details>

### Type ExecutionStatus<sup><sub><sup> [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L17)</sup></sub></sup>
### Type ExecutionStatus<sup><sub><sup> [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L18)</sup></sub></sup>


<details><summary>Details</summary><p>
Expand All @@ -681,23 +681,23 @@ Supported Fields:

| | Field | Type | Default | Example | Description |
| --- | --- | --- | --- | --- | --- |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L46-L48) | canExpand | `boolean` | `false` | | Indicates if the concepts that are included in the query description can be accesed by the user. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L41-L43) | columnDescriptions | list of `ColumnDescriptor` | `null` | | Holds a description for each column, present in the result. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L27) | createdAt | `ZonedDateTime` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L35) | id | ID of `ManagedExecution` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L25) | label | `String` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L28) | lastUsed | `ZonedDateTime` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L37) | numberOfResults | `long` or `null` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L32) | own | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L29) | owner | ID of `User` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L30) | ownerName | `String` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L51-L53) | query | [QueryDescription](#Base-QueryDescription) | `null` | | Is set to the query description if the user can expand all included concepts. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L38) | requiredTime | `long` or `null` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L39) | resultUrl | `URL` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L31) | shared | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L36) | status | one of NEW, RUNNING, CANCELED, FAILED, DONE | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L33) | system | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L24) | tags | list of `String` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L48-L50) | canExpand | `boolean` | `false` | | Indicates if the concepts that are included in the query description can be accesed by the user. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L43-L45) | columnDescriptions | list of `ColumnDescriptor` | `null` | | Holds a description for each column, present in the result. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L29) | createdAt | `ZonedDateTime` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L37) | id | ID of `ManagedExecution` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L26) | label | `String` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L30) | lastUsed | `ZonedDateTime` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L39) | numberOfResults | `long` or `null` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L34) | own | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L31) | owner | ID of `User` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L32) | ownerName | `String` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L53-L55) | query | [QueryDescription](#Base-QueryDescription) | `null` | | Is set to the query description if the user can expand all included concepts. |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L40) | requiredTime | `long` or `null` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L41) | resultUrl | `URL` | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L33) | shared | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L38) | status | one of NEW, RUNNING, CANCELED, FAILED, DONE | `null` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L35) | system | `boolean` | `false` | | |
| [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/execution/ExecutionStatus.java#L25) | tags | list of `String` | `null` | | |
</p></details>

### Type FERoot<sup><sub><sup> [](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/models/api/description/FERoot.java#L10-L12)</sup></sub></sup>
Expand Down
53 changes: 35 additions & 18 deletions frontend/src/js/app/RightPane.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
import React from "react";
import { connect } from "react-redux";
import React, { FC } from "react";
import { useSelector } from "react-redux";
import styled from "@emotion/styled";
import type { StateT } from "app-types";

import type { TabT } from "../pane/types";

import Pane from "../pane/Pane";

type PropsType = {
interface PropsT {
tabs: TabT[];
activeTab: string;
selectedDatasetId: string | null;
};
}

const Tab = styled("div")<{ isActive: boolean }>`
height: 100%;
flex-grow: 1;
display: flex;
flex-direction: column;
display: ${({ isActive }) => (isActive ? "flex" : "none")};
`;

const RightPane = ({ tabs, activeTab, selectedDatasetId }: PropsType) => {
// Won't be null, since the activeTabs string is built from tabs
// during setup
const theActiveTab = tabs.find(tab => tab.key === activeTab);
const RightPane: FC<PropsT> = ({ tabs }) => {
const activeTab = useSelector<StateT, string>(
(state) => state.panes.right.activeTab
);
const selectedDatasetId = useSelector<StateT, string | null>(
(state) => state.datasets.selectedDatasetId
);

const tab = React.createElement(theActiveTab.component, {
selectedDatasetId: selectedDatasetId
});
return (
<Pane right>
{tabs.map((tab) => {
const isActive = tab.key === activeTab;
const tabComponent = React.createElement(tab.component, {
selectedDatasetId: selectedDatasetId,
});

return <Pane right>{tab}</Pane>;
return <Tab isActive={isActive}>{tabComponent}</Tab>;
})}
</Pane>
);
};

export default connect(state => ({
activeTab: state.panes.right.activeTab,
selectedDatasetId: state.datasets.selectedDatasetId
}))(RightPane);
export default RightPane;
2 changes: 2 additions & 0 deletions frontend/src/js/concept-trees-open/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
SET_CONCEPT_OPEN,
CLOSE_ALL_CONCEPT_OPEN,
} from "./actionTypes";
import { SEARCH_TREES_SUCCESS } from "../concept-trees/actionTypes";

export type ConceptTreesOpenStateT = {
[conceptId: string]: boolean;
Expand All @@ -25,6 +26,7 @@ const conceptTreesOpen = (
all[conceptId] = false;
return all;
}, {});
case SEARCH_TREES_SUCCESS:
case RESET_ALL_CONCEPT_OPEN:
return initialState;
default:
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/js/concept-trees/ConceptTreeFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const ConceptTreeFolder: FC<PropsT> = ({
? null
: sumMatchingEntries(tree.children, tree.matchingEntries);

const isOpen = open || search.allOpen;

return (
<Root>
<ConceptTreeNodeTextContainer
Expand All @@ -77,7 +79,7 @@ const ConceptTreeFolder: FC<PropsT> = ({
onTextClick={onToggleOpen}
search={search}
/>
{open &&
{isOpen &&
tree.children &&
tree.children.map((childId, i) => {
const tree = trees[childId];
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/js/external-forms/FormsNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ const FormsNavigation: FC = () => {
const onItemClick = (form: string) => dispatch(setExternalForm(form));

const locale = getLocale();
const options = Object.values(availableForms).map((formType) => ({
label: formType.headline[locale],
value: formType.type,
}));
const options = Object.values(availableForms)
.map((formType) => ({
label: formType.headline[locale]!,
value: formType.type,
}))
.sort((a, b) => (a.label < b.label ? -1 : 1));

return (
<Root>
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/js/pane/Pane.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as React from "react";
import React, { FC } from "react";
import styled from "@emotion/styled";
import PaneTabNavigation from "./PaneTabNavigation";

type PropsType = {
interface PropsT {
right?: boolean;
left?: boolean;
children?: React.Node;
};
}

const Root = styled("div")`
const Root = styled("div")<{ left?: boolean; right?: boolean }>`
width: 100%;
height: 100%;
Expand All @@ -23,14 +22,14 @@ const Container = styled("div")`
position: relative;
`;

const Pane = (props: PropsType) => {
const paneType = props.left ? "left" : "right";
const Pane: FC<PropsT> = ({ left, right, children }) => {
const paneType = left ? "left" : "right";

return (
<Root left={props.left} right={props.right}>
<Root left={left} right={right}>
<Container>
<PaneTabNavigation paneType={paneType} />
<Container className="pane__body">{props.children}</Container>
<Container>{children}</Container>
</Container>
</Root>
);
Expand Down
81 changes: 60 additions & 21 deletions frontend/src/js/preview/ColumnStats.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from "react";
import { ColumnDescriptionType } from "./Preview";
import styled from "@emotion/styled";
import T from "i18n-react";

const Stats = styled("div")`
padding: 0 10px 10px 0;
Expand Down Expand Up @@ -32,18 +33,45 @@ interface Props {
rawColumnData: string[];
}

function getVarianceFromAvg(arr: number[], avg: number) {
const diffs = arr.map((val) => Math.abs(avg - val));
const sumDiffs = diffs.reduce((a, b) => a + b, 0);
// Might come in handy at some point
// function getVarianceFromAvg(arr: number[], avg: number) {
// const diffs = arr.map((val) => Math.abs(avg - val));
// const sumDiffs = diffs.reduce((a, b) => a + b, 0);

return sumDiffs / arr.length;
// return sumDiffs / arr.length;
// }

function getStdDeviationFromAvg(arr: number[], avg: number) {
const squareDiffs = arr.map((val) => {
const diff = Math.abs(avg - val);

return diff * diff;
});

const sumSquareDiffs = squareDiffs.reduce((a, b) => a + b, 0);

return Math.sqrt(sumSquareDiffs / arr.length);
}

function getMedian(sortedArr: number[]) {
if (sortedArr.length === 0) return 0;

const half = Math.floor(sortedArr.length / 2);

return sortedArr.length % 2 === 1
? sortedArr[half]
: (sortedArr[half - 1] + sortedArr[half]) / 2.0;
}

function toRoundedDecimalsString(num: number, decimals: number) {
const factor = Math.pow(10, decimals);
const rounded = Math.round(num * factor) / factor;

return rounded.toFixed(decimals);
return rounded.toFixed(decimals).replace(".", ",");
}

function toLocalizedNumberString(num: number) {
return num.toString().replace(".", ",");
}

const parseMoney = (str: string) => {
Expand All @@ -57,10 +85,11 @@ const ColumnStats: FC<Props> = ({ colName, columnType, rawColumnData }) => {
case "NUMERIC":
case "MONEY":
case "INTEGER": {
const cleanData = rawColumnData
const cleanSortedData = rawColumnData
.slice(1)
.filter((x) => !!x)
.map((x) => {
if (!x) return 0;

switch (columnType) {
case "INTEGER":
return parseInt(x);
Expand All @@ -69,32 +98,42 @@ const ColumnStats: FC<Props> = ({ colName, columnType, rawColumnData }) => {
case "MONEY":
return parseMoney(x);
}
});
const sum = cleanData.reduce((a, b) => a + b, 0);
const avg = sum / cleanData.length;
const min = Math.min(...cleanData);
const max = Math.max(...cleanData);
const variance = getVarianceFromAvg(cleanData, avg);
})
.sort((a, b) => a - b);

const sum = cleanSortedData.reduce((a, b) => a + b, 0);
const median = getMedian(cleanSortedData);
const avg = sum / cleanSortedData.length;
const min = cleanSortedData[0];
const max = cleanSortedData[cleanSortedData.length - 1];
const std = getStdDeviationFromAvg(cleanSortedData, avg);
const decimals = 2;
// Might come in handy at some point
// const variance = getVarianceFromAvg(cleanSortedData, avg);

return (
<Stats>
<Name>{colName}</Name>
<Values>
<Stat>
<Label>avg:</Label>
<Value>{toRoundedDecimalsString(avg, 2)}</Value>
<Label>{T.translate("common.average")}:</Label>
<Value>{toRoundedDecimalsString(avg, decimals)}</Value>
</Stat>
<Stat>
<Label>{T.translate("common.median")}:</Label>
<Value>{toLocalizedNumberString(median)}</Value>
</Stat>
<Stat>
<Label>min:</Label>
<Value>{min}</Value>
<Label>{T.translate("common.min")}:</Label>
<Value>{toLocalizedNumberString(min)}</Value>
</Stat>
<Stat>
<Label>max:</Label>
<Value>{max}</Value>
<Label>{T.translate("common.max")}:</Label>
<Value>{toLocalizedNumberString(max)}</Value>
</Stat>
<Stat>
<Label>var:</Label>
<Value>{toRoundedDecimalsString(variance, 2)}</Value>
<Label>{T.translate("common.std")}:</Label>
<Value>{toRoundedDecimalsString(std, decimals)}</Value>
</Stat>
</Values>
</Stats>
Expand Down
24 changes: 4 additions & 20 deletions frontend/src/js/previous-queries/list/DeletePreviousQueryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import React from "react";
import T from "i18n-react";

import DeleteModal from "../../modal/DeleteModal";
import { deleteStoredQuery } from "../../api/api";
import { useDispatch, useSelector } from "react-redux";
import { StateT } from "app-types";
import type { DatasetIdT } from "../../api/types";
import { setMessage } from "../../snack-message/actions";
import { useDeletePreviousQuery } from "./useDeletePreviousQuery";

interface PropsType {
previousQueryId: string;
Expand All @@ -19,22 +15,10 @@ const DeletePreviousQueryModal = ({
onClose,
onDeleteSuccess,
}: PropsType) => {
const datasetId = useSelector<StateT, DatasetIdT | null>(
(state) => state.datasets.selectedDatasetId
const { onDeletePreviousQuery } = useDeletePreviousQuery(
previousQueryId,
onDeleteSuccess
);
const dispatch = useDispatch();

async function onDeletePreviousQuery() {
if (!datasetId) return;

try {
await deleteStoredQuery(datasetId, previousQueryId);

onDeleteSuccess();
} catch (e) {
dispatch(setMessage("previousQuery.deleteError"));
}
}

return (
<DeleteModal
Expand Down
Loading

0 comments on commit 0be8f1b

Please sign in to comment.