view: int_dbt_prod_restrictions_subaccount_store {
  derived_table: {sql:

    SELECT * FROM intelligence.dbt_prod.restrictions_subaccount_store
    WHERE {% condition distribution_type %} distribution_type {% endcondition %};;
  }

  dimension: subaccount_id {
    type: number
    sql: ${TABLE}.subaccount_id ;;
    hidden: yes
  }


  dimension: list_aggregate_restrictions {
    label: "Restrictions by Store (List)"
    group_label: "Restrictions"
    type: string
    sql: ${TABLE}.list_aggregate_restrictions ;;
    html:
    {% assign countries = value | split: ";" %}
    {% unless countries.size == 0 %}

      <details>
      <summary>Detail ({{countries.size}})</summary>

      <ul>
      {% for country in countries %}
      <li>{{country}}</li>
      {% endfor %}
      </ul>
      </details>

      {% endunless %}
      ;;
  }

  filter: distribution_type {
    label: "Distribution Type"
    group_label: "Restrictions"
    description: "Use this to filter store restrictions based on a distribution type (full track, ringtone, etc)"
    type: string
  }
}
