How to use the plywood.TimeRange.fromJS 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 allegro / turnilo / src / client / visualizations / line-chart / line-chart.tsx View on Github external
floorRange(dragRange: PlywoodRange): PlywoodRange | null {
    const { essence } = this.props;
    const { splits, timezone } = essence;
    const continuousSplit = splits.splits.last();
    if (!continuousSplit.bucket) return dragRange; // temp solution for non-bucketed reaching here

    if (TimeRange.isTimeRange(dragRange)) {
      const duration = continuousSplit.bucket as Duration;
      return TimeRange.fromJS({
        start: duration.floor(dragRange.start, timezone),
        end: duration.shift(duration.floor(dragRange.end, timezone), timezone, 1)
      });
    }
    if (NumberRange.isNumberRange(dragRange)) {
      const bucketSize = continuousSplit.bucket as number;
      const startFloored = roundTo((dragRange as NumberRange).start, bucketSize);
      let endFloored = roundTo((dragRange as NumberRange).end, bucketSize);

      if (endFloored - startFloored < bucketSize) {
        endFloored += bucketSize;
      }

      return NumberRange.fromJS({
        start: startFloored,
        end: endFloored
github geo-opensource / pivot / src / server / utils / settings-manager / settings-manager.ts View on Github external
.then((maxTime: Date) => {
              maxTime = new Date(maxTime);
              if (isNaN(maxTime as any)) throw new Error('invalid maxTime');
              var lastTwoWeeks = TimeRange.fromJS({
                start: day.move(maxTime, Timezone.UTC, -14),
                end: maxTime
              });
              return $('temp').filter(primaryTimeExpression.in(lastTwoWeeks)).limit(PREVIEW_LIMIT).compute(context) as any;
            });
        } else {
github allegro / turnilo / src / client / components / highlighter / highlighter.mocha.tsx View on Github external
it("adds the correct class", () => {
    var fakeTimeRange = TimeRange.fromJS({
      start: new Date("2015-01-26T04:54:10Z"),
      end: new Date("2015-01-26T05:54:10Z")
    });

    var myScaleX = (value: any) => 42;

    var renderedComponent = renderIntoDocument(
      
    );

    expect(TestUtils.isCompositeComponent(renderedComponent), "should be composite").to.equal(true);
    expect((ReactDOM.findDOMNode(renderedComponent) as Element).className, "should contain class").to.contain("highlighter");
  });
github geo-opensource / pivot / src / client / components / time-filter-menu / time-filter-menu.tsx View on Github external
constructFilter(): Filter {
    var { essence, dimension } = this.props;
    var { tab, startTime, endTime } = this.state;
    var { filter } = essence;
    var { timezone } = essence;

    if (tab !== 'specific') return null;

    if (startTime && !endTime) {
      endTime = day.shift(startTime, timezone, 1);
    }

    if (startTime && endTime && startTime < endTime) {
      return filter.setSelection(dimension.expression, r(TimeRange.fromJS({ start: startTime, end: endTime })));
    } else {
      return null;
    }
  }
github hortonworks / streamline / pivot / src / server / utils / settings-manager / settings-manager.ts View on Github external
* limitations under the License.
 */

import * as Q from 'q';
import { Timezone, day } from 'chronoshift';
import { $, Executor, basicExecutorFactory, find, Attributes, Dataset, TimeRange } from 'plywood';
import { Logger } from 'logger-tracker';
import { TimeMonitor } from "../../../common/utils/time-monitor/time-monitor";
import { AppSettings, Timekeeper, Cluster, DataCube } from '../../../common/models/index';
import { SettingsStore } from '../settings-store/settings-store';
import { FileManager } from '../file-manager/file-manager';
import { ClusterManager } from '../cluster-manager/cluster-manager';
import { updater } from '../updater/updater';

const PREVIEW_LIMIT = 20;
const LOTS_OF_TIME = TimeRange.fromJS({
  start: new Date('1000-01-01Z'),
  end: new Date('4000-01-01Z')
});

export interface SettingsManagerOptions {
  logger: Logger;
  verbose?: boolean;
  initialLoadTimeout?: number;
  anchorPath: string;
}

export interface GetSettingsOptions {
  dataCubeOfInterest?: string;
  timeout?: number;
}
github implydata / plyql / src / cli.ts View on Github external
var end: Date = null;
  var duration: Duration = null;
  if (p0[0] === 'P') {
    duration = Duration.fromJS(p0);
    end = new Date(p1);
    start = duration.move(end, Timezone.UTC, -1);
  } else if (p1[0] === 'P') {
    start = new Date(p0);
    duration = Duration.fromJS(p1);
    end = duration.move(end, Timezone.UTC, 1);
  } else {
    start = new Date(p0);
    end = new Date(p1);
  }

  return TimeRange.fromJS({ start, end });
}
github allegro / turnilo / src / common / models / time-preset / time-preset.ts View on Github external
static fromJS(parameters: TimePresetJS): TimePreset {
    return new TimePreset({
      name: parameters.name,
      timeRange: TimeRange.fromJS(parameters.timeRange)
    });
  }