version: 2
models:
  - name: FANS_BY_CUSTOM_LIST_ACCOUNT_COUNTRY_DATE_DBT
    description: '{{ doc("FANS_BY_CUSTOM_LIST_ACCOUNT_COUNTRY_DATE_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - COUNTRY_ISO2
            - FIRST_EVENT_DATE
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: VENDOR_ID
        description: Vendor ID from Orchard
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID from Orchard
        data_tests:
          - not_null
      - name: CUSTOM_LIST_ID
        description: Custom list id from CRM
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: Country in ISO2 format
        data_tests:
          - not_null
      - name: FIRST_EVENT_DATE
        description: Date when fan activity took place
        data_tests:
          - not_null
      - name: FANS_COUNT
        description: Count of unique fans
        data_tests:
          - not_null
  - name: FANS_BY_CUSTOM_LIST_ACCOUNT_COUNTRY_DBT
    description: '{{ doc("FANS_BY_CUSTOM_LIST_ACCOUNT_COUNTRY_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - COUNTRY_ISO2
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: VENDOR_ID
        description: Vendor ID from Orchard
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID from Orchard
        data_tests:
          - not_null
      - name: CUSTOM_LIST_ID
        description: Custom list id from CRM
        data_tests:
          - not_null
      - name: CUSTOM_LIST_NAME
        description: Custom list name
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: Country code in ISO2 format
        data_tests:
          - not_null
      - name: FANS_COUNT
        description: Count of unique fans
        data_tests:
          - not_null
      - name: FANS_SHARE
        description: Share of fans
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
      - name: FANS_COUNT_7_DAYS_AGO
        description: Fans count 7 days ago
        data_tests:
          - not_null
      - name: FANS_COUNT_28_DAYS_AGO
        description: Fans count 28 days ago
        data_tests:
          - not_null
      - name: FANS_COUNT_6_MONTH_AGO
        description: Fans count 6 month ago
        data_tests:
          - not_null
      - name: FANS_COUNT_1_YEAR_AGO
        description: Fans count 1 year (365 days) ago
        data_tests:
          - not_null
      - name: EMAIL_CONSENT_FANS_COUNT
        description: Nr of fans with email consent
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '<= FANS_COUNT'
      - name: AD_CONSENT_FANS_COUNT
        description: Nr of fans with ad consent
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '<= FANS_COUNT'
