mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 11:34:18 +00:00
Add new diario method
This commit is contained in:
parent
b7c7db8a82
commit
8d6c57ad30
3 changed files with 38 additions and 1 deletions
|
@ -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 <ste.pigozzi@gmail.com>"]
|
||||
license = "AGPL-3.0+"
|
||||
|
|
|
@ -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__
|
||||
|
|
35
royalpack/stars/api_diario_range.py
Normal file
35
royalpack/stars/api_diario_range.py
Normal 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
|
Loading…
Reference in a new issue