1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
royalnet/wikipack/stars/api_wiki_list.py
2020-06-26 02:41:32 +02:00

47 lines
1.1 KiB
Python

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,
}
@rca.magic
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]