diff --git a/pyproject.toml b/pyproject.toml index d145ee11..4372e9e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "royalpack" - version = "5.14.4" + version = "5.14.5" description = "A Royalnet command pack for the Royal Games community" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" diff --git a/royalpack/stars/__init__.py b/royalpack/stars/__init__.py index 393ead1d..db031fd5 100644 --- a/royalpack/stars/__init__.py +++ b/royalpack/stars/__init__.py @@ -13,6 +13,7 @@ from .api_user_ryg import ApiUserRygStar from .api_user_ryg_list import ApiUserRygListStar from .api_user_avatar import ApiUserAvatarStar from .api_auth_login_osu import ApiAuthLoginOsuStar +from .api_diario_range import ApiDiarioRangeStar # Enter the PageStars of your Pack here! available_page_stars = [ @@ -30,6 +31,7 @@ available_page_stars = [ ApiUserRygListStar, ApiUserAvatarStar, ApiAuthLoginOsuStar, + ApiDiarioRangeStar, ] # Don't change this, it should automatically generate __all__ diff --git a/royalpack/stars/api_diario_range.py b/royalpack/stars/api_diario_range.py new file mode 100644 index 00000000..1e4c506b --- /dev/null +++ b/royalpack/stars/api_diario_range.py @@ -0,0 +1,35 @@ +from typing import * +import royalnet.constellation.api as rca +import royalnet.utils as ru +from ..tables import * + + +class ApiDiarioRangeStar(rca.ApiStar): + path = "/api/diario/range/v3" + + tags = ["diario"] + + parameters = { + "get": { + "start": "The starting diario_id (included).", + "end": "The final diario_id (excluded).", + } + } + + @rca.magic + async def get(self, data: rca.ApiData) -> ru.JSON: + """Get the diario entries in the specified range.""" + DiarioT = self.alchemy.get(Diario) + + entries: List[Diario] = await ru.asyncify( + data.session + .query(DiarioT) + .filter( + DiarioT.diario_id >= data.int("start", optional=False), + DiarioT.diario_id < data.int("end", optional=False) + ) + .order_by(DiarioT.diario_id) + .all + ) + response = [entry.json() for entry in entries] + return response