"""
Clip feature views for recommendation system.
"""

from datetime import timedelta
from feast import FeatureView, Field
from feast.infra.offline_stores.snowflake_source import SnowflakeSource
from feast.types import Bool

from .entities import clip
from .config import get_snowflake_database, get_snowflake_schema

# Snowflake data source for hook features
clip_features_source = SnowflakeSource(
    name="clip_features_snowflake",
    database=get_snowflake_database(),
    schema=get_snowflake_schema(),
    table="RECS_HOOKS_RANKER_CLIP_FEATURE_STORE",
    timestamp_field="EVENT_TIMESTAMP",
    created_timestamp_column="CREATED_TIMESTAMP",
)

# Clip features
clip_features = FeatureView(
    name="clip_features",
    description="Clip features including genre",
    entities=[clip],
    ttl=timedelta(days=365),  # Keep features for 30 days
    schema=[
        # Note: Don't include clip_id here - it's specified via entities=[clip]
        Field(
            name="GENRE_AMBIENT",
            dtype=Bool,
            description="Boolean indicating if the clip is ambient",
        ),
        Field(
            name="GENRE_CLASSICAL",
            dtype=Bool,
            description="Boolean indicating if the clip is classical",
        ),
        Field(
            name="GENRE_COUNTRY",
            dtype=Bool,
            description="Boolean indicating if the clip is country",
        ),
        Field(
            name="GENRE_DANCE",
            dtype=Bool,
            description="Boolean indicating if the clip is dance",
        ),
        Field(
            name="GENRE_ELECTRONIC",
            dtype=Bool,
            description="Boolean indicating if the clip is electronic",
        ),
        Field(
            name="GENRE_EXPERIMENTAL",
            dtype=Bool,
            description="Boolean indicating if the clip is experimental",
        ),
        Field(
            name="GENRE_FOLK",
            dtype=Bool,
            description="Boolean indicating if the clip is folk",
        ),
        Field(
            name="GENRE_FUNK",
            dtype=Bool,
            description="Boolean indicating if the clip is funk",
        ),
        Field(
            name="GENRE_HIP_HOP",
            dtype=Bool,
            description="Boolean indicating if the clip is hip hop",
        ),
        Field(
            name="GENRE_JAZZ",
            dtype=Bool,
            description="Boolean indicating if the clip is jazz",
        ),
        Field(
            name="GENRE_LATIN",
            dtype=Bool,
            description="Boolean indicating if the clip is latin",
        ),
        Field(
            name="GENRE_METAL",
            dtype=Bool,
            description="Boolean indicating if the clip is metal",
        ),
        Field(
            name="GENRE_POP",
            dtype=Bool,
            description="Boolean indicating if the clip is pop",
        ),
        Field(
            name="GENRE_RANDB",
            dtype=Bool,
            description="Boolean indicating if the clip is R&B",
        ),
        Field(
            name="GENRE_REGGAE",
            dtype=Bool,
            description="Boolean indicating if the clip is reggae",
        ),
        Field(
            name="GENRE_ROCK",
            dtype=Bool,
            description="Boolean indicating if the clip is rock",
        ),
        Field(
            name="GENRE_SOUL",
            dtype=Bool,
            description="Boolean indicating if the clip is soul",
        ),
        Field(
            name="GENRE_SOUNDTRACK",
            dtype=Bool,
            description="Boolean indicating if the clip is soundtrack",
        ),
    ],
    source=clip_features_source,
    online=True,  # Available for online serving
    tags={"team": "recs"},
)
