legato v0.2.0 Legato.Query View Source

Link to this section Summary

Link to this section Functions

Link to this function between(query, start_date, end_date) View Source
Link to this function dimensions(profile, names) View Source

Add dimensions to an existing Legato.Query

Examples

iex> %Legato.Query{} |> Legato.Query.dimensions([:country]) |> Legato.Query.dimensions([:city]) %Legato.Query{

dimensions: [%Legato.Query.Dimension{name: "ga:country"}, %Legato.Query.Dimension{name: "ga:city"}]

}

Link to this function filter(query, name, operator, value) View Source

Add filter to set for dimensions and metrics

Checks for the name of the dimension or metric in a predefined set. If the value is dynamic (e.g. custom variables like :dimension_x_x) it will not know if it is a dimension or metric name. This limitation can be circumvented creating the MetricFilter or DimensionFilter struct yourself.

Examples

iex> %Legato.Query{} |> Legato.Query.filter(:pageviews, :gt, 10) %Legato.Query{

filters: %{
  dimensions: %Legato.Query.FilterSet{as: :dimensions},
  metrics: %Legato.Query.FilterSet{as: :metrics, operator: :or, filters: [
    %Legato.Query.MetricFilter{
      metric_name: :pageviews,
      not: false,
      operator: :gt,
      comparison_value: 10
    }
  ]}
}

}

iex> %Legato.Query{} |> Legato.Query.filter(:continent, :like, [“North America”, “Europe”]) %Legato.Query{

filters: %{
  metrics: %Legato.Query.FilterSet{as: :metrics},
  dimensions: %Legato.Query.FilterSet{as: :dimensions, operator: :or, filters: [
    %Legato.Query.DimensionFilter{
      dimension_name: :continent,
      not: false,
      operator: :like,
      case_sensitive: false,
      expressions: ["North America", "Europe"]
    }
  ]}
}

}

Add metrics to an existing Legato.Query

Examples

iex> %Legato.Query{} |> Legato.Query.metrics([:pageviews]) |> Legato.Query.metrics([:exits]) %Legato.Query{

metrics: [%Legato.Query.Metric{expression: "ga:pageviews"}, %Legato.Query.Metric{expression: "ga:exits"}]

}

Link to this function order_by(query, name, direction \\ :ascending) View Source

Adds a single segment id

Examples

iex> %Legato.Query{} |> Legato.Query.segment(-3) %Legato.Query{segments: [%Legato.Query.Segment{segment_id: “gaid:-3”}]}