Automated Action 9ed9654f1e Enhance Anime Information API with Advanced Features
- Add advanced search filters (year range, score, studio, source)
- Create detailed statistics endpoint for anime collection
- Implement enhanced pagination metadata for better navigation
- Add sorting options for search results
- Enhance anime model with additional fields (season info, ratings, etc.)
- Add ability to search anime by character attributes
- Create migration for new anime model fields
- Update README with detailed documentation of new features
2025-05-17 22:10:44 +00:00

47 lines
2.3 KiB
Python

from sqlalchemy import Column, Integer, String, Float, Text, Date, Boolean, JSON
from sqlalchemy.orm import relationship
from app.db.base_class import Base
class Anime(Base):
id = Column(Integer, primary_key=True, index=True)
title = Column(String(255), index=True, nullable=False)
alternative_titles = Column(String(500), nullable=True)
synopsis = Column(Text, nullable=True)
episodes = Column(Integer, nullable=True)
status = Column(String(50), nullable=True) # airing, finished, upcoming
aired_from = Column(Date, nullable=True)
aired_to = Column(Date, nullable=True)
duration = Column(String(50), nullable=True) # per episode (e.g., "24 min per ep")
rating = Column(String(50), nullable=True) # PG-13, R, etc.
score = Column(Float, nullable=True)
ranked = Column(Integer, nullable=True)
popularity = Column(Integer, nullable=True)
studio = Column(String(100), nullable=True)
source = Column(String(50), nullable=True) # manga, light novel, etc.
image_url = Column(String(255), nullable=True)
# New fields: Season information
season = Column(String(20), nullable=True) # "Winter", "Spring", "Summer", "Fall"
season_year = Column(Integer, nullable=True) # Year of the season
# New fields: Rating details
score_count = Column(Integer, nullable=True) # Number of people who rated
favorites_count = Column(Integer, nullable=True) # Number of people who favorited
# Additional metadata
broadcast_day = Column(String(20), nullable=True) # Day of the week
broadcast_time = Column(String(20), nullable=True) # Time of day
is_airing = Column(Boolean, nullable=True) # Whether it's currently airing
licensors = Column(String(255), nullable=True) # Companies with licenses
producers = Column(String(255), nullable=True) # Production companies
# Related anime info
related_anime = Column(JSON, nullable=True) # JSON field to store related anime info
# Content tags
themes = Column(String(255), nullable=True) # Themes like "School", "Military"
demographics = Column(String(100), nullable=True) # Target audience like "Shounen", "Seinen"
# Relationships
characters = relationship("Character", back_populates="anime", cascade="all, delete-orphan")