Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

2.0 KB
Raw Blame
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";

const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;

export const regularQuestion = {
  name: "Orders4t#7 t3",
  description: "Foo",
  query: {
    "source-table": ORDERS_ID,
    limit: 5,
    expressions: { Math: ["+", 1, 1] },
  },
  visualization_settings: {
    column_settings: {
      [`["ref",["field",${ORDERS.CREATED_AT},null]]`]: {
        date_abbreviate: true,
        date_style: "dddd, MMMM D, YYYY",
        time_enabled: "seconds",
        time_style: "HH:mm",
      },
      [`["ref",["field",${ORDERS.TOTAL},null]]`]: {
        column_title: "Billed",
        number_style: "currency",
        currency_in_header: false,
        currency: "EUR",
        currency_style: "symbol",
      },
      [`["ref",["field",${ORDERS.TAX},null]]`]: { show_mini_bar: true },
    },
  },
};

export const questionWithAggregation = {
  ...regularQuestion,
  query: {
    ...regularQuestion.query,
    aggregation: [["count"]],
    breakout: [
      [
        "field",
        ORDERS.CREATED_AT,
        {
          "temporal-unit": "month",
        },
      ],
      ["expression", "Math", null],
    ],
  },
  display: "line",
};

export const joinedQuestion = {
  ...regularQuestion,
  query: {
    ...regularQuestion.query,
    joins: [
      {
        fields: "all",
        "source-table": PEOPLE_ID,
        condition: [
          "=",
          ["field", ORDERS.USER_ID, null],
          [
            "field",
            PEOPLE.ID,
            {
              "join-alias": "User",
            },
          ],
        ],
        alias: "User",
      },
    ],
  },
};

export const questionAsPinMapWithTiles = {
  name: "Orders",
  description: "Foo",
  enable_embedding: true,
  native: {
    query: "SELECT LATITUDE, LONGITUDE FROM PEOPLE ORDER BY ID LIMIT 10",
  },
  display: "map",
  visualization_settings: {
    "map.type": "pin",
    "map.pin_type": "tiles",
    "map.longitude_column": "LONGITUDE",
    "map.latitude_column": "LATITUDE",
  },
};