Skip to content

Commit

Permalink
Renames for brevity
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmroz-allegro committed Mar 17, 2022
1 parent 5855c3d commit 6b985b9
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 44 deletions.
8 changes: 4 additions & 4 deletions src/client/deserializers/app-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/

import { ClientAppSettings, SerializedAppSettings } from "../../common/models/app-settings/app-settings";
import { deserialize as customizationDeserialize } from "./customization";
import { deserialize as oauthDeserialize } from "./oauth";
import { deserialize as deserializeCustomization } from "./customization";
import { deserialize as deserializeOauth } from "./oauth";

export function deserialize({ oauth, clientTimeout, customization, version }: SerializedAppSettings): ClientAppSettings {
return {
clientTimeout,
version,
customization: customizationDeserialize(customization),
oauth: oauthDeserialize(oauth)
customization: deserializeCustomization(customization),
oauth: deserializeOauth(oauth)
};
}
4 changes: 2 additions & 2 deletions src/client/deserializers/customization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Timezone } from "chronoshift";
import { ClientCustomization, SerializedCustomization } from "../../common/models/customization/customization";
import { deserialize as localeDeserialize } from "../../common/models/locale/locale";
import { deserialize as deserializeLocale } from "../../common/models/locale/locale";

export function deserialize(customization: SerializedCustomization): ClientCustomization {
const { headerBackground, locale, customLogoSvg, timezones, externalViews, hasUrlShortener, sentryDSN } = customization;
Expand All @@ -26,7 +26,7 @@ export function deserialize(customization: SerializedCustomization): ClientCusto
externalViews,
hasUrlShortener,
sentryDSN,
locale: localeDeserialize(locale),
locale: deserializeLocale(locale),
timezones: timezones.map(Timezone.fromJS)
};
}
16 changes: 8 additions & 8 deletions src/client/deserializers/data-cube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import { Duration, Timezone } from "chronoshift";
import { AttributeInfo, Executor } from "plywood";
import { ClientDataCube, SerializedDataCube } from "../../common/models/data-cube/data-cube";
import { serialize as dimensionsSerialize } from "../../common/models/dimension/dimensions";
import { serialize as serializeDimensions } from "../../common/models/dimension/dimensions";
import { Filter } from "../../common/models/filter/filter";
import { serialize as measuresSerialize } from "../../common/models/measure/measures";
import { serialize as serializeMeasures } from "../../common/models/measure/measures";
import { RefreshRule } from "../../common/models/refresh-rule/refresh-rule";
import { deserialize as dimensionsDeserialize } from "./dimensions";
import { deserialize as measuresDeserialize } from "./measures";
import { deserialize as deserializeDimensions } from "./dimensions";
import { deserialize as deserializeMeasures } from "./measures";

export function deserialize(dataCube: SerializedDataCube, executor: Executor): ClientDataCube {
const {
Expand Down Expand Up @@ -60,12 +60,12 @@ export function deserialize(dataCube: SerializedDataCube, executor: Executor): C
defaultSplitDimensions,
defaultTimezone: Timezone.fromJS(defaultTimezone),
description,
dimensions: dimensionsDeserialize(dimensions),
dimensions: deserializeDimensions(dimensions),
executor,
extendedDescription,
group,
maxSplits,
measures: measuresDeserialize(measures),
measures: deserializeMeasures(measures),
name,
options,
refreshRule: RefreshRule.fromJS(refreshRule),
Expand Down Expand Up @@ -116,11 +116,11 @@ export function serialize(dataCube: ClientDataCube): SerializedDataCube {
defaultSplitDimensions,
defaultTimezone: defaultTimezone.toJS(),
description,
dimensions: dimensionsSerialize(dimensions),
dimensions: serializeDimensions(dimensions),
extendedDescription,
group,
maxSplits,
measures: measuresSerialize(measures),
measures: serializeMeasures(measures),
name,
options,
refreshRule: RefreshRule.fromJS(refreshRule),
Expand Down
4 changes: 2 additions & 2 deletions src/client/deserializers/dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import { ClientDimensions, SerializedDimensions } from "../../common/models/dimension/dimensions";
import { mapValues } from "../../common/utils/object/object";
import { deserialize as dimensionDeserialize } from "./dimension";
import { deserialize as deserializeDimension } from "./dimension";

export function deserialize({ tree, byName }: SerializedDimensions): ClientDimensions {
return {
tree,
byName: mapValues(byName, dimensionDeserialize)
byName: mapValues(byName, deserializeDimension)
};
}
4 changes: 2 additions & 2 deletions src/client/deserializers/measures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import { ClientMeasures, SerializedMeasures } from "../../common/models/measure/measures";
import { mapValues } from "../../common/utils/object/object";
import { deserialize as measureDeserialize } from "./measure";
import { deserialize as deserializeMeasure } from "./measure";

export function deserialize({ tree, byName }: SerializedMeasures): ClientMeasures {
return {
tree,
byName: mapValues(byName, measureDeserialize)
byName: mapValues(byName, deserializeMeasure)
};
}
8 changes: 4 additions & 4 deletions src/client/deserializers/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import { ClientAppSettings } from "../../common/models/app-settings/app-settings
import { SerializedDataCube } from "../../common/models/data-cube/data-cube";
import { ClientSources, SerializedSources } from "../../common/models/sources/sources";
import { Ajax } from "../utils/ajax/ajax";
import { deserialize as clusterDeserialize } from "./cluster";
import { deserialize as dataCubeDeserialize } from "./data-cube";
import { deserialize as deserializeCluster } from "./cluster";
import { deserialize as deserializeDataCube } from "./data-cube";

export function deserialize(settings: SerializedSources, appSettings: ClientAppSettings): ClientSources {
const clusters = settings.clusters.map(clusterDeserialize);
const clusters = settings.clusters.map(deserializeCluster);

const dataCubes = settings.dataCubes.map((dataCube: SerializedDataCube) => {
const executor = Ajax.queryUrlExecutorFactory(dataCube.name, appSettings);
return dataCubeDeserialize(dataCube, executor);
return deserializeDataCube(dataCube, executor);
});

return {
Expand Down
8 changes: 4 additions & 4 deletions src/common/models/app-settings/app-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import {
Customization,
CustomizationJS,
fromConfig as customizationFromConfig,
serialize as customizationSerialize,
serialize as serializeCustomization,
SerializedCustomization
} from "../customization/customization";
import {
fromConfig as oauthFromConfig,
Oauth,
OauthJS,
serialize as oauthSerialize,
serialize as serializeOauth,
SerializedOauth
} from "../oauth/oauth";

Expand Down Expand Up @@ -82,8 +82,8 @@ export function serialize({ oauth, clientTimeout, customization, version }: AppS
return {
clientTimeout,
version,
customization: customizationSerialize(customization),
oauth: oauthSerialize(oauth)
customization: serializeCustomization(customization),
oauth: serializeOauth(oauth)
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/models/cluster/cluster.mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use(equivalent);

describe("Cluster", () => {
describe("fromConfig", () => {
it("should load defaults", () => {
it("should load default values", () => {
const cluster = fromConfig({
name: "foobar",
url: "http://bazz"
Expand Down
8 changes: 3 additions & 5 deletions src/common/models/customization/customization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { LOGGER } from "../../logger/logger";
import { assoc } from "../../utils/functional/functional";
import { isTruthy } from "../../utils/general/general";
import { ExternalView, ExternalViewValue } from "../external-view/external-view";
import { fromConfig as localeFromConfig, Locale, LocaleJS, serialize as localeSerialize } from "../locale/locale";
import { fromConfig as localeFromConfig, Locale, LocaleJS, serialize as serializeLocale } from "../locale/locale";
import { fromConfig as urlShortenerFromConfig, UrlShortener, UrlShortenerDef } from "../url-shortener/url-shortener";

export const DEFAULT_TITLE = "Turnilo (%v)";
Expand Down Expand Up @@ -184,7 +184,7 @@ export function fromConfig(config: CustomizationJS = {}): Customization {
? configExternalViews.map(ExternalView.fromJS)
: [];

const customization = {
return {
title,
headerBackground,
customLogoSvg,
Expand All @@ -195,8 +195,6 @@ export function fromConfig(config: CustomizationJS = {}): Customization {
locale: localeFromConfig(locale),
externalViews
};

return customization;
}

export function serialize(customization: Customization): SerializedCustomization {
Expand All @@ -207,7 +205,7 @@ export function serialize(customization: Customization): SerializedCustomization
hasUrlShortener: isTruthy(urlShortener),
headerBackground,
sentryDSN,
locale: localeSerialize(locale),
locale: serializeLocale(locale),
timezones: timezones.map(t => t.toJS())
};
}
Expand Down
9 changes: 5 additions & 4 deletions src/common/models/data-cube/data-cube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
findDimensionByName,
fromConfig as dimensionsFromConfig,
prepend,
serialize as dimensionsSerialize,
serialize as serializeDimensions,
SerializedDimensions
} from "../dimension/dimensions";
import { RelativeTimeFilterClause, TimeFilterPeriod } from "../filter-clause/filter-clause";
Expand All @@ -54,7 +54,8 @@ import {
hasMeasureWithName,
MeasureOrGroupJS,
Measures,
serialize as measuresSerialize, SerializedMeasures
serialize as serializeMeasures,
SerializedMeasures
} from "../measure/measures";
import { QueryDecoratorDefinition, QueryDecoratorDefinitionJS } from "../query-decorator/query-decorator";
import { RefreshRule, RefreshRuleJS } from "../refresh-rule/refresh-rule";
Expand Down Expand Up @@ -433,11 +434,11 @@ export function serialize(dataCube: DataCube): SerializedDataCube {
defaultSplitDimensions,
defaultTimezone: defaultTimezone.toJS(),
description,
dimensions: dimensionsSerialize(dimensions),
dimensions: serializeDimensions(dimensions),
extendedDescription,
group,
maxSplits,
measures: measuresSerialize(measures),
measures: serializeMeasures(measures),
name,
options,
refreshRule: refreshRule.toJS(),
Expand Down
4 changes: 2 additions & 2 deletions src/common/models/dimension/dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Dimension,
DimensionJS,
fromConfig as dimensionFromConfig,
serialize as dimensionSerialize,
serialize as serializeDimension,
SerializedDimension
} from "./dimension";

Expand Down Expand Up @@ -105,7 +105,7 @@ export interface SerializedDimensions {
export function serialize({ tree, byName }: Dimensions): SerializedDimensions {
return {
tree,
byName: mapValues(byName, dimensionSerialize)
byName: mapValues(byName, serializeDimension)
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/models/measure/measures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
fromConfig as measureFromConfig,
Measure,
MeasureJS,
serialize as measureSerialize,
serialize as serializeMeasure,
SerializedMeasure
} from "./measure";

Expand Down Expand Up @@ -107,7 +107,7 @@ export type ClientMeasures = Measures;
export function serialize({ tree, byName }: Measures): SerializedMeasures {
return {
tree,
byName: mapValues(byName, measureSerialize)
byName: mapValues(byName, serializeMeasure)
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/common/models/sources/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
Cluster,
ClusterJS,
fromConfig as clusterFromConfig,
serialize as clusterSerialize,
serialize as serializeCluster,
SerializedCluster
} from "../cluster/cluster";
import { findCluster } from "../cluster/find-cluster";
Expand All @@ -30,7 +30,7 @@ import {
DataCube,
DataCubeJS,
fromConfig as dataCubeFromConfig,
serialize as dataCubeSerialize,
serialize as serializeDataCube,
SerializedDataCube
} from "../data-cube/data-cube";
import { isQueryable, QueryableDataCube } from "../data-cube/queryable-data-cube";
Expand Down Expand Up @@ -99,11 +99,11 @@ export function serialize({
clusters: serverClusters,
dataCubes: serverDataCubes
}: Sources): SerializedSources {
const clusters = serverClusters.map(clusterSerialize);
const clusters = serverClusters.map(serializeCluster);

const dataCubes = serverDataCubes
.filter(dc => isQueryable(dc))
.map(dataCubeSerialize);
.map(serializeDataCube);

return {
clusters,
Expand Down

0 comments on commit 6b985b9

Please sign in to comment.