# View: publishing_app_compositions_changes

**View Name:** publishing_app_compositions_changes
**Table Source:** `Derived from: Qa.Cdc_Musicgraph_Publishingcomposition`
**File Path:** `views/publishing/publishing_app_compositions_changes.view.lkml`

## Overview

- **File Size:** 3268 bytes
- **Lines of Code:** 80
- **Dimensions:** 6
- **Measures:** 0
- **Dimension Groups:** 0
- **Filters:** 0

## Dimensions

| Name | Type |
|------|------|
| `id` | number |
| `title` | string |
| `alternate_title` | string |
| `ISWC` | string |
| `contains_sample` | string |
| `contains_public_domain` | string |

## SQL Comments

- will this work?
- COMPOSITIONS CHANGES QUERY

## Derived Table

```sql
sql:
    set days_diff = 3; --will this work?
--COMPOSITIONS CHANGES QUERY
SELECT
    RECORD_CONTENT:payload:before:properties.id as id,
  iff(
    RECORD_CONTENT:payload:after:properties:title != RECORD_CONTENT:payload:before:properties:title,
    CONCAT_WS(' / ', CONCAT_WS(': ', 'Before', RECORD_CONTENT:payload:before:properties:title), CONCAT_WS(': ','After', RECORD_CONTENT:payload:after:properties:title)),
    ''
  ) as title,
  iff(
    RECORD_CONTENT:payload:after:properties:alternateTitles != RECORD_CONTENT:payload:before:properties:alternateTitles,
    CONCAT_WS(' / ', CONCAT_WS(': ', 'Before', RECORD_CONTENT:payload:before:properties:alternateTitles), CONCAT_WS(': ','After', RECORD_CONTENT:payload:after:properties:alternateTitles)),
    ''
  ) as alternate_title,
  iff(
    RECORD_CONTENT:payload:after:properties:iswc != RECORD_CONTENT:payload:before:properties:iswc,
    CONCAT_WS(' / ', CONCAT_WS(': ', 'Before', RECORD_CONTENT:payload:before:properties:iswc), CONCAT_WS(': ','After', RECORD_CONTENT:payload:after:properties:iswc)),
    ''
  ) as iswc,
  iff(
    RECORD_CONTENT:payload:after:properties:containsSample != RECORD_CONTENT:payload:before:properties:containsSample,
    CONCAT_WS(' / ', CONCAT_WS(': ', 'Before', RECORD_CONTENT:payload:before:properties:containsSample), CONCAT_WS(': ','After', RECORD_CONTENT:payload:after:properties:containsSample)),
    ''
  ) as contains_sample,
  iff(
    RECORD_CONTENT:payload:after:properties:containsPublicDomain != RECORD_CONTENT:payload:before:properties:containsPublicDomain,
    CONCAT_WS(' / ', CONCAT_WS(': ', 'Before', RECORD_CONTENT:payload:before:properties:containsPublicDomain), CONCAT_WS(': ','After', RECORD_CONTENT:payload:after:properties:containsPublicDomain)),
    ''
  ) as contains_public_domain
FROM FACTS.QA.CDC_MUSICGRAPH_PUBLISHINGCOMPOSITION
WHERE (
    RECORD_CONTENT:meta:operation = 'updated' AND
    RECORD_CONTENT:payload:before:properties:draft = false AND
    RECORD_CONTENT:payload:after:properties:draft = false AND
  (
    RECORD_CONTENT:payload:after:properties:title != RECORD_CONTENT:payload:before:properties:title OR
    RECORD_CONTENT:payload:after:properties:alternateTitles != RECORD_CONTENT:payload:before:properties:alternateTitles OR
    RECORD_CONTENT:payload:after:properties:iswc != RECORD_CONTENT:payload:before:properties:iswc OR
    RECORD_CONTENT:payload:after:properties:containsSample != RECORD_CONTENT:payload:before:properties:containsSample OR
    RECORD_CONTENT:payload:after:properties:containsPublicDomain != RECORD_CONTENT:payload:before:properties:containsPublicDomain
  )
) AND timediff(day, date(RECORD_CONTENT:meta:timestamp), current_date()) < $days_diff

    ;;
```

