view: project_moments_hedra_output_140_days_table {
sql_table_name: intelligence.dbt_prod_project_moments.hedra_output_140_days ;;

  dimension: transaction_country_code {
    view_label: "Territory"
    label: "Country Code"
    type: string
    sql: ${TABLE}.transaction_country_code ;;
  }




  dimension: isrc {
    view_label: "Track"
    label: "ISRC"
    type: string
    sql: ${TABLE}.ISRC ;;
    link: {
      label: "Insights Link"
      url:"

      {% if _explore._name == 'project_moments_hedra_output_140_days_table' %}

      https://insights.theorchard.com/song/{{project_moments_hedra_output_140_days_table.isrc._value}}/?areaView=enabled&period=past6Months&country={{project_moments_hedra_output_140_days_table.transaction_country_code._value}}&store=286&potGraphType=AREA&dimension=sourceofstreams

      {% endif %}

      "

    }
  }


  dimension: isrc_key {
    view_label: "Track"
    label: "ISRC Key"
    primary_key: yes
    type: string
    sql: ${TABLE}.ISRC_KEY ;;

  }

  dimension: track_name {
    view_label: "Track"
    label: "Track Name"
    type: string
    sql: ${TABLE}.track_name ;;

  }

  dimension_group: release {
    view_label: "Release"
    label: "Release Date"
    type: time
    description: "Original date of release"
    timeframes: [date, day_of_week, week_of_year, week, month, year]
    sql: ${TABLE}.release_date ;;
    convert_tz: no
  }

  dimension: artist_name {
    view_label: "Artist"
    label: "Artist Name"
    type: string
    sql: ${TABLE}.artist_name ;;

  }

  dimension: artist_id {
    view_label: "Artist"
    label: "Artist ID"
    type: number
    value_format_name: id
    sql: ${TABLE}.artist_id ;;

  }

  dimension_group: snapshot_start_date {
    view_label: "Date Frame"
    label: "Snapshot Start Date"
    type: time
    timeframes: [date, day_of_week, week_of_year, week, month, year]
    sql: ${TABLE}.snapshot_period_start ;;
    convert_tz: no
  }

  dimension_group: snapshot_start_end {
    view_label: "Date Frame"
    label: "Snapshot Start End"
    type: time
    timeframes: [date, day_of_week, week_of_year, week, month, year]
    sql: ${TABLE}.snapshot_period_end ;;
    convert_tz: no
  }

  dimension: streams {
    view_label: "Metrics"
    label: "Streams"
    type: number
    sql: ${TABLE}.streams ;;

  }

  dimension: active_streams {
    view_label: "Metrics"
    label: "Active Streams"
    type: number
    sql: ${TABLE}.active_streams ;;

  }

 # dimension: search_streams {
 #   view_label: "Metrics"
 #   label: "Search Streams"
 #   type: number
 #   sql: ${TABLE}.search_streams ;;
 #
 # }

  dimension: avg_streams_rolling7d_ma {
    view_label: "Metrics"
    label: "Avg Streams Rolling 7 Day MA"
    type: number
    value_format: "0"
    sql: ${TABLE}.avg_streams_rolling7d_ma ;;

  }

  dimension: avg_active_streams_rolling7d_ma {
    view_label: "Metrics"
    label: "Avg Active Streams Rolling 7 Day MA"
    type: number
    value_format: "0"
    sql: ${TABLE}.avg_active_streams_rolling7d_ma ;;

  }

  #dimension: avg_search_streams_rolling7d_ma {
  #  view_label: "Metrics"
  #  label: "Avg Search Streams Rolling 7 Day MA"
  #  type: number
  #  value_format: "0"
  #  sql: ${TABLE}.avg_search_streams_rolling7d_ma ;;
  #
  #}

  dimension: error_streams_total {
    view_label: "Metrics"
    label: "Error Streams (Total)"
    type: number
    value_format: "0"
    sql: ${TABLE}.error_streams_total ;;

  }

  dimension: error_active_streams_total {
    view_label: "Metrics"
    label: "Error Streams (Active)"
    type: number
    value_format: "0"
    sql: ${TABLE}.error_active_streams_total ;;

  }

  #dimension: error_search_streams_total {
  #  view_label: "Metrics"
  #  label: "Error Streams (Search)"
  #  type: number
  #  value_format: "0"
  #  sql: ${TABLE}.error_search_streams_total ;;
  #
  #}

  dimension: error_streams_rank {
    view_label: "Metrics"
    label: "Error Streams Rank (Total)"
    type: number
    value_format: "0"
    sql: ${TABLE}.error_streams_rank ;;

  }

  dimension: error_active_streams_rank {
    view_label: "Metrics"
    label: "Error Streams Rank (Active)"
    type: number
    value_format: "0"
    sql: ${TABLE}.error_active_streams_rank ;;

  }

  #dimension: error_search_streams_rank {
  #  view_label: "Metrics"
  #  label: "Error Streams Rank (Search)"
  #  type: number
  #  value_format: "0"
  # sql: ${TABLE}.error_search_streams_rank ;;
  #
  #}

}
