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

48 lines
1.1 KiB
Python
Raw Normal View History

2020-06-22 16:29:02 +00:00
from typing import *
import datetime
import royalnet.constellation.api as rca
import royalnet.utils as ru
import royalnet.backpack.tables as rbt
from ..tables import *
import sqlalchemy as s
class ApiWikiListStar(rca.ApiStar):
path = "/api/wiki/list/v2"
tags = ["wiki"]
parameters = {
"get": {},
}
auth = {
"get": False,
}
2020-06-26 00:41:32 +00:00
@rca.magic
2020-06-22 16:29:02 +00:00
async def get(self, data: rca.ApiData) -> ru.JSON:
"""Get the details of a specific Wiki page."""
WikiRevisionT = self.alchemy.get(WikiRevision)
lrs = await ru.asyncify(
data.session
.query(WikiRevisionT.page_id, s.func.max(WikiRevisionT.revision_id))
.group_by(WikiRevisionT.page_id)
.all
)
pages = []
for page_id, revision_id in lrs:
page = await ru.asyncify(
data.session
.query(WikiRevisionT)
.get,
(page_id, revision_id)
)
pages.append(page)
return [r.json_list() for r in pages]