view: int_prod_rsd_release_schedule_dashboard {
  sql_table_name: intelligence.prod.rsd_release_schedule_dashboard ;;

 # PRIMARY KEY
  dimension: release_id {
    type: number
    sql: ${TABLE}.release_id ;;
    primary_key: yes
    hidden: yes
  }

  dimension: release_date {
    type: date
    sql: ${TABLE}.release_date ;;
  }

  dimension: is_active_release {
    label: "Is Active Release?"
    sql: ${TABLE}.release_status='in_content'
              AND ${TABLE}.deletions!='Y'
              AND ${TABLE}.not_for_distribution='N';;
    description: "Releases that have the following criteria:
    Release Status = in_content;
    NOT Deleted;
    (Not-Not) For Distribution"
    type: yesno
  }

  dimension: sale_start_date {
    type: date
    sql: ${TABLE}.sale_start_date ;;
  }

  dimension: preorder_date {
    type: date
    sql: ${TABLE}.preorder_date ;;
  }

  dimension: last_updated {
    type:date
    sql: ${TABLE}.last_updated ;;
  }

  dimension: upc {
    label: "UPC"
    type: string
    sql: ${TABLE}.upc ;;
  }

  dimension: artist_id {
    type: number
    sql: ${TABLE}.artist_id ;;
  }

  dimension: artist_name {
    type: string
    sql: ${TABLE}.artist_name ;;
  }

  dimension: artist_country {
    type: string
    sql: ${TABLE}.artist_country ;;
  }

  dimension: release_name {
    type: string
    sql: ${TABLE}.release_name ;;
  }

  dimension: imprint {
    type: string
    sql: ${TABLE}.imprint ;;
  }

  dimension: genre {
    type: string
    sql: ${TABLE}.genre ;;
  }

  dimension: subgenre {
    type: string
    sql: ${TABLE}.subgenre ;;
  }

  dimension: label_id {
    type: number
    sql: ${TABLE}.label_id ;;
  }

  dimension: label_name {
    type: string
    sql: ${TABLE}.label_name ;;
  }

  dimension: label_country {
    type: string
    sql:${TABLE}.label_country ;;
  }

  dimension: label_manager {
    type: string
    sql: ${TABLE}.label_manager ;;
  }

  dimension: context_type {
    case: {
      when: {
        sql: ${TABLE}.context_type = 'digital' ;;
        label: "Digital"
      }
      when: {
        sql: ${TABLE}.context_type = 'physical' ;;
        label: "Physical"
      }
    }
  }

  dimension: release_format {
    type: string
    sql: ${TABLE}.release_format ;;
  }

  dimension: media_format {
    type: string
    sql: ${TABLE}.media_format ;;
  }

  dimension: display_configuration {
    type: string
    sql: ${TABLE}.display_configuration ;;
  }

  dimension: mktg_blurb {
    label: "Marketing Blurb"
    type: string
    sql: ${TABLE}.mktg_blurb ;;
    html:
    {% assign blurb = value %}
    {% unless blurb.size == 0 %}

    <details>
    <summary>Expand</summary>
    {{blurb}}
    </details>

    {% endunless %}
    ;;
  }

  dimension: global_mktg_highlights {
    label: "Global Marketing Highlights"
    type: string
    sql: ${TABLE}.global_mktg_highlights ;;
    html:
    {% assign highlights = value %}
    {% unless highlights.size == 0 %}

    <details>
    <summary>Expand</summary>
    {{highlights}}
    </details>

    {% endunless %}
    ;;
  }

  dimension: sync_highlights {
    label: "Sync Highlights"
    type: string
    sql: ${TABLE}.sync_highlights ;;
    html:
    {% assign highlights = value %}
    {% unless highlights.size == 0 %}

    <details>
    <summary>Expand</summary>
    {{highlights}}
    </details>

    {% endunless %}
    ;;
  }

  dimension: local_mktg_highlights {
    label: "Local Marketing Highlights"
    type: string
    sql: ${TABLE}.local_mktg_highlights ;;
    html:
    {% assign countries = value | split: "||" %}
    {% unless countries.size == 0 %}

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

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

    {% endunless %}
    ;;
  }

  dimension: store_specific_highlights {
    type: string
    sql: ${TABLE}.store_specific_highlights ;;
    html:
    {% assign stores = value | split: "||" %}
    {% unless stores.size == 0 %}

      <details>
      <summary>Expand ({{stores.size}})</summary>

      <ul>
      {% for store in stores %}
      <li>{{store}}</li>
      {% endfor %}
      </ul>
      </details>

    {% endunless %}
    ;;
  }

  dimension: internal_note {
    type: string
    sql: ${TABLE}.internal_note ;;
    html:
    {% assign internal_note = value %}
    {% unless internal_note.size == 0 %}

    <details>
    <summary>Expand</summary>
    {{internal_note}}
    </details>

    {% endunless %}
    ;;
  }

  dimension: project_description {
    type: string
    sql: ${TABLE}.project_description ;;
    html:
    {% assign project_description = value %}
    {% unless project_description.size == 0 %}

    <details>
    <summary>Expand</summary>
    {{project_description}}
    </details>

    {% endunless %}
    ;;
  }

  dimension: promo_link {
    type: string
    sql: ${TABLE}.promo_link ;;
    html:
    {% assign link = value %}
    <a href="{{link}}"><u>Promo Link</u></a>
    ;;
  }

  dimension: priority {
    type: string
    sql: ${TABLE}.priority ;;
  }

  dimension: priority_ab {
    type: string
    sql: ${TABLE}.priority_ab ;;
  }

  dimension: priority_a {
    type: string
    sql: ${TABLE}.priority_a ;;
    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 %}
    ;;
  }

  dimension: priority_b {
    type: string
    sql: ${TABLE}.priority_b ;;
    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 %}
    ;;
  }

  dimension: release_status {
    case: {
      when: { sql: ${TABLE}.release_status = 'in_content' ;; label: "In Content" }
      when: { sql: ${TABLE}.release_status = 'orchard_processing' ;; label: "Orchard Processing" }
      when: { sql: ${TABLE}.release_status = 'label_processing' ;; label: "Label Processing" }
      when: { sql: ${TABLE}.release_status = 'transfer_to_content' ;; label: "Transfer to Content" }
      when: { sql: ${TABLE}.release_status = 'label_confirmation' ;; label: "Label Confirmation" }
    }
  }

  dimension: contains_lyrics {
    type: yesno
    sql:  ${TABLE}.mktg_blurb is not null
      and ${TABLE}.mktg_blurb !='';;
  }
}
