from datetime import date
from typing import Optional, Iterator

from sqlmodel import SQLModel, Field, create_engine, Session  # type: ignore[import]

from my_feed.log import logger
from app.settings import settings


# base non-table sql model
class FeedBase(SQLModel):  # type: ignore[misc]
    model_id: str
    ftype: str  # feed item type
    title: str
    score: Optional[float] = Field(default=None)

    # more metadata
    subtitle: Optional[str] = Field(default=None)
    creator: Optional[str] = Field(default=None)
    part: Optional[int] = Field(default=None)
    subpart: Optional[int] = Field(default=None)
    collection: Optional[str] = Field(default=None)

    # dates
    when: int
    release_date: Optional[date] = 