version: 2
models:
  - name: gov__fact_stake_accounts
    description: "{{ doc('fact_stake_accounts') }}"
    recent_date_filter: &recent_date_filter
      config:
        where: modified_timestamp >= current_date - 7
    tests:
      - reference_tx_missing:
          reference_tables:
            - 'silver__snapshot_stake_accounts_2'
          id_column: 'stake_pubkey'
    columns:
      - name: epoch
        description: "{{ doc('epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: stake_pubkey
        description: "{{ doc('stake_account') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: vote_pubkey
        description: "{{ doc('vote_pubkey') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: authorized_staker
        description: "{{ doc('authorized_staker') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: authorized_withdrawer
        description: "{{ doc('withdraw_authority') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: lockup
        description: "{{ doc('lockup') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: rent_exempt_reserve
        description: "{{ doc('rent_exempt_reserve') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: credits_observed
        description: "{{ doc('credits_observed') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: activation_epoch
        description: "{{ doc('activation_epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: deactivation_epoch
        description: "{{ doc('deactivation_epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: active_stake
        description: "{{ doc('stake_balance') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: warmup_cooldown_rate
        description: "{{ doc('warmup_cooldown_rate') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: type_stake
        description: "{{ doc('stake_type') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: program
        description: "{{ doc('program') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: account_sol
        description: "{{ doc('stake_account_sol') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: rent_epoch
        description: "{{ doc('rent_epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: FACT_STAKE_ACCOUNTS_ID
        description: '{{ doc("pk") }}'
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
          - unique: *recent_date_filter    
      - name: INSERTED_TIMESTAMP
        description: '{{ doc("inserted_timestamp") }}' 
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter   
      - name: MODIFIED_TIMESTAMP
        description: '{{ doc("modified_timestamp") }}' 
        tests:
          - dbt_expectations.expect_column_to_exist
