"""Queries and views for the <area> team (GP4).

Each person replaces one query stub and one view stub with their own work,
renames them, and puts their name in the docstrings. Every function takes the
session first, so that GP5's endpoints can pass theirs in.

Run every function at once, on SQLite or (with DATABASE_URL) on PostgreSQL:

    python -m planner.<area>.queries

Add imports as you need them, such as:

    from sqlalchemy import exists, func, text
    from sqlmodel import select

    from planner.core import CURRENT_TERM, TODAY, Person, Student

Import only what you use, since ruff check fails on an unused import.
"""

from sqlmodel import Session, SQLModel

from planner.core import engine

# ---------------------------------------------------------------------------
# SQLModel queries: one per person, written with select(), not SQL text.
# Each has a join, plus an aggregate, a subquery, or an outer join.
# ---------------------------------------------------------------------------


def query_one(session: Session) -> list:
    """Author: First Last. Which question from the README does this answer?"""
    return []


def query_two(session: Session) -> list:
    """Author: First Last. Which question from the README does this answer?"""
    return []


def query_three(session: Session) -> list:
    """Author: First Last. Which question from the README does this answer?"""
    return []


def query_four(session: Session) -> list:
    """Author: First Last. Which question from the README does this answer?"""
    return []


# ---------------------------------------------------------------------------
# Views: one class and one function for each view in queries.sql.
# The class has a field for each column of the view, and no table=True.
# The function selects from the view with text(), binding any parameter.
# ---------------------------------------------------------------------------


class ViewOne(SQLModel):
    """One row of <area>_view_one."""


def view_one(session: Session) -> list[ViewOne]:
    """Author: First Last. Which question from the README does this answer?"""
    return []


class ViewTwo(SQLModel):
    """One row of <area>_view_two."""


def view_two(session: Session) -> list[ViewTwo]:
    """Author: First Last. Which question from the README does this answer?"""
    return []


class ViewThree(SQLModel):
    """One row of <area>_view_three."""


def view_three(session: Session) -> list[ViewThree]:
    """Author: First Last. Which question from the README does this answer?"""
    return []


class ViewFour(SQLModel):
    """One row of <area>_view_four."""


def view_four(session: Session) -> list[ViewFour]:
    """Author: First Last. Which question from the README does this answer?"""
    return []


# Every function, called with the session alone, so give each of their
# other parameters a default value (such as CURRENT_TERM).
FUNCTIONS = [
    query_one,
    query_two,
    query_three,
    query_four,
    view_one,
    view_two,
    view_three,
    view_four,
]

if __name__ == "__main__":
    with Session(engine) as session:
        for function in FUNCTIONS:
            rows = function(session)
            print(f"\n{function.__name__}: {len(rows)} rows")
            for row in rows[:5]:
                print("  ", row)
