1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add new diario method

This commit is contained in:
Steffo 2020-08-29 23:59:45 +02:00
parent b7c7db8a82
commit 8d6c57ad30
3 changed files with 38 additions and 1 deletions

View file

@ -2,7 +2,7 @@
[tool.poetry] [tool.poetry]
name = "royalpack" name = "royalpack"
version = "5.14.4" version = "5.14.5"
description = "A Royalnet command pack for the Royal Games community" description = "A Royalnet command pack for the Royal Games community"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"] authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+" license = "AGPL-3.0+"

View file

@ -13,6 +13,7 @@ from .api_user_ryg import ApiUserRygStar
from .api_user_ryg_list import ApiUserRygListStar from .api_user_ryg_list import ApiUserRygListStar
from .api_user_avatar import ApiUserAvatarStar from .api_user_avatar import ApiUserAvatarStar
from .api_auth_login_osu import ApiAuthLoginOsuStar from .api_auth_login_osu import ApiAuthLoginOsuStar
from .api_diario_range import ApiDiarioRangeStar
# Enter the PageStars of your Pack here! # Enter the PageStars of your Pack here!
available_page_stars = [ available_page_stars = [
@ -30,6 +31,7 @@ available_page_stars = [
ApiUserRygListStar, ApiUserRygListStar,
ApiUserAvatarStar, ApiUserAvatarStar,
ApiAuthLoginOsuStar, ApiAuthLoginOsuStar,
ApiDiarioRangeStar,
] ]
# Don't change this, it should automatically generate __all__ # Don't change this, it should automatically generate __all__

View file

@ -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