mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
498d0688b0
+ add Mix db model
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from flask_openapi3 import Tag
|
|
from flask_openapi3 import APIBlueprint
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.api.apischemas import GenericLimitSchema
|
|
from app.lib.home.recentlyadded import get_recently_added_items
|
|
from app.lib.home.recentlyplayed import get_recently_played
|
|
from app.store.homepage import HomepageStore
|
|
|
|
bp_tag = Tag(name="Home", description="Homepage items")
|
|
api = APIBlueprint("home", __name__, url_prefix="/home", abp_tags=[bp_tag])
|
|
|
|
|
|
@api.get("/recents/added")
|
|
def get_recently_added(query: GenericLimitSchema):
|
|
"""
|
|
Get recently added
|
|
"""
|
|
return {"items": get_recently_added_items(query.limit)}
|
|
|
|
|
|
@api.get("/recents/played")
|
|
def get_recent_plays(query: GenericLimitSchema):
|
|
"""
|
|
Get recently played
|
|
"""
|
|
return {"items": get_recently_played(query.limit)}
|
|
|
|
|
|
class HomepageItem(BaseModel):
|
|
limit: int = Field(
|
|
default=9, description="The max number of items per group to return"
|
|
)
|
|
|
|
|
|
@api.get("/")
|
|
def homepage_items(query: HomepageItem):
|
|
return {
|
|
"artist_mixes": HomepageStore.get_mixes("artist_mixes", limit=query.limit),
|
|
}
|