How to use the plywood.ply function in plywood

To help you get started, we’ve selected a few plywood examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geo-opensource / pivot / src / client / visualizations / base-visualization / base-visualization.tsx View on Github external
protected makeQuery(essence: Essence, timekeeper: Timekeeper): Expression {
    var { splits, colors, dataCube } = essence;
    var measures = essence.getEffectiveMeasures();

    var $main = $('main');

    var query = ply()
      .apply('main', $main.filter(essence.getEffectiveFilter(timekeeper, this.id).toExpression()));

    measures.forEach((measure) => {
      query = query.performAction(measure.toApplyAction());
    });

    function makeSubQuery(i: number): Expression {
      var split = splits.get(i);
      var splitDimension = dataCube.getDimensionByExpression(split.expression);
      var { sortAction, limitAction } = split;
      if (!sortAction) {
        throw new Error('something went wrong during query generation');
      }

      var subQuery: Expression = $main.split(split.toSplitExpression(), splitDimension.name);
github allegro / turnilo / src / common / utils / query / visualization-query.ts View on Github external
export default function makeQuery(essence: Essence, timekeeper: Timekeeper): Expression {
  const { splits, dataCube } = essence;
  if (splits.length() > dataCube.getMaxSplits()) throw new Error(`Too many splits in query. DataCube "${dataCube.name}" supports only ${dataCube.getMaxSplits()} splits`);

  const hasComparison = essence.hasComparison();
  const mainFilter = essence.getEffectiveFilter(timekeeper, { combineWithPrevious: hasComparison });

  const timeShiftEnv: TimeShiftEnv = essence.getTimeShiftEnv(timekeeper);

  const mainExp: Expression = ply()
    .apply("main", $main.filter(mainFilter.toExpression(dataCube)))
    .apply(CANONICAL_LENGTH_ID, timeFilterCanonicalLength(essence, timekeeper));

  const queryWithMeasures = applySeries(essence.getConcreteSeries(), timeShiftEnv)(mainExp);

  if (splits.length() > 0) {
    return queryWithMeasures
      .apply(SPLIT, applySplit(0, essence, timeShiftEnv));
  }
  return queryWithMeasures;
}
github allegro / turnilo / src / client / components / number-range-picker / number-range-picker.tsx View on Github external
fetchData(essence: Essence, timekeeper: Timekeeper, dimension: Dimension, rightBound: number): void {
    const { dataCube } = essence;
    const filterExpression = essence.getEffectiveFilter(timekeeper, { unfilterDimension: dimension }).toExpression(dataCube);
    const $main = $("main");
    const query = ply()
      .apply("main", $main.filter(filterExpression))
      .apply("Min", $main.min($(dimension.name)))
      .apply("Max", $main.max($(dimension.name)));

    this.setState({
      loading: true
    });

    dataCube.executor(query)
      .then(
        (dataset: Dataset) => {
          if (!this.mounted) return;
          var min = (dataset.data[0]["Min"] as number);
          var max = (dataset.data[0]["Max"] as number);

          var step = max && min && isFinite(max) && isFinite(min) ? (max - min) / rightBound : 1;
github geo-opensource / pivot / src / client / components / number-range-picker / number-range-picker.tsx View on Github external
fetchData(essence: Essence, timekeeper: Timekeeper, dimension: Dimension, rightBound: number): void {
    var { dataCube } = essence;
    var filterExpression = essence.getEffectiveFilter(timekeeper, null, dimension).toExpression();
    var $main = $('main');
    var query = ply()
      .apply('main', $main.filter(filterExpression))
      .apply('Min', $main.min($(dimension.name)))
      .apply('Max', $main.max($(dimension.name)));

    this.setState({
      loading: true
    });

    QueryRunner.fetch(dataCube, query, Timezone.UTC)
      .then(
        (dataset: Dataset) => {
          if (!this.mounted) return;
          var min = (dataset.data[0]['Min'] as number);
          var max = (dataset.data[0]['Max'] as number);

          var step = max && min && isFinite(max) && isFinite(min) ? (max - min) / rightBound : 1;
github allegro / turnilo / src / common / models / data-cube / data-cube.ts View on Github external
static queryMaxTime(dataCube: DataCube): Promise {
    if (!dataCube.executor) {
      return Promise.reject(new Error("dataCube not ready"));
    }

    const ex = ply().apply("maxTime", $("main").max(dataCube.timeAttribute));

    return dataCube.executor(ex).then((dataset: Dataset) => {
      const maxTimeDate = dataset.data[0]["maxTime"] as Date;
      if (isNaN(maxTimeDate as any)) return null;
      return maxTimeDate;
    });
  }