version: 2

models:
  - name: fact_credit_topup
    description: Credit topups from Stripe and RevenueCat.
    config:
      schema: "prod"
      group: finance
      tags: ['partition_type=daily', 'automation_condition=daily_cron_with_eager_historical_backfill_condition']
    meta:
      dagster:
        partition_start_date: "2024-03-25"  # Matches ORPHEUS_PROJECT_START_DATE
        end_offset: 0
        backfill_policy:
          max_partitions_per_run: -1
    columns:
      - name: id
        description: Unique identifier for the credit topup
      - name: user_id
        description: Unique identifier for the user
      - name: user_uid
        description: User UID
      - name: billing_provider
        description: Billing provider
      - name: purchased_on_platform
        description: Platform where the credit topup was purchased
      - name: provider_customer_id
        description: Provider customer ID
      - name: provider_transaction_id
        description: Provider transaction ID
      - name: provider_product_id
        description: Provider product ID
      - name: provider_product_name
        description: Provider product name
      - name: n_credits
        description: Number of credits purchased
      - name: purchased_ts_utc
        description: Timestamp of when the credit topup was purchased
    
  - name: subscription_spans
    description: Enriched subscription spans with additional plan and user details.
    config:
      group: subscriptions
      tags: ["cadence=daily", "dbt"]
    columns:
      - name: user_id
        description: Unique identifier for the user
      - name: first_subscription_ts
        description: Timestamp of when the subscription span started
      - name: last_active_ts
        description: Timestamp of when the subscription span ends. Can be in the future, especially for annual plans.
      - name: last_period_canceled_at_ts
        description: Timestamp of when the last subscription in this span was canceled (if any)
      - name: months_active
        description: Number of months between first subscription ts and last active ts
      - name: subscribed_on_platform
        description: Platform where the subscription was purchased
      - name: initial_subscription_plan_id
        description: The subscription plan at the start of the span (dim_subscription_plan id)
      - name: final_subscription_plan_id
        description: The subscription plan at the end of the span (dim_subscription_plan id)
      - name: initial_renewal_interval
        description: The renewal interval of the first subscription in this span (month or year)
      - name: final_renewal_interval
        description: The renewal interval of the last subscription in this span (month or year)
      - name: count_separate_subscriptions
        description: The number of separate subscription purchases within this continuous span
      - name: is_user_first_subscription_span
        description: Boolean indicating if this is the user's first subscription span ever
      # User dimension attributes
      - name: country
        description: The recent country where the user is located (most common in L60D)
      - name: registered_platform
        description: The platform where the user initially registered
      - name: region
        description: The geographical region of the user (most common in L60D)
      - name: meets_bot_definition
        description: Boolean indicating if the user meets the criteria to be classified as a bot
