From e6db8d248ab969e0329b054a16667786e9e70fb5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Jun 2020 18:29:02 +0200 Subject: [PATCH] publish: 1.0.0 --- publish.bat | 2 ++ pyproject.toml | 4 +-- wikipack/stars/__init__.py | 4 ++- wikipack/stars/api_wiki_list.py | 48 +++++++++++++++++++++++++++++++++ wikipack/version.py | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 publish.bat create mode 100644 wikipack/stars/api_wiki_list.py diff --git a/publish.bat b/publish.bat new file mode 100644 index 00000000..39d5c62e --- /dev/null +++ b/publish.bat @@ -0,0 +1,2 @@ +git commit -am "publish: %1" +git push && poetry build && poetry publish && hub release create "%1" -m "Wikipack %1" diff --git a/pyproject.toml b/pyproject.toml index 6da163be..61838c5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [tool.poetry] name = "wikipack" description = "A Wiki for Royalnet" - version = "0.1.0" + version = "1.0.0" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" homepage = "https://github.com/Steffo99/wikipack/" @@ -20,7 +20,7 @@ python = "^3.8" [tool.poetry.dependencies.royalnet] - version = "~5.8.16" + version = "~5.9.0" extras = [ "alchemy_easy", "constellation", diff --git a/wikipack/stars/__init__.py b/wikipack/stars/__init__.py index 4ed81310..3c471f8e 100644 --- a/wikipack/stars/__init__.py +++ b/wikipack/stars/__init__.py @@ -1,9 +1,11 @@ # Imports go here! from .api_wiki import ApiWikiStar +from .api_wiki_list import ApiWikiListStar # Enter the PageStars of your Pack here! available_page_stars = [ - ApiWikiStar + ApiWikiStar, + ApiWikiListStar, ] # Don't change this, it should automatically generate __all__ diff --git a/wikipack/stars/api_wiki_list.py b/wikipack/stars/api_wiki_list.py new file mode 100644 index 00000000..94584b9e --- /dev/null +++ b/wikipack/stars/api_wiki_list.py @@ -0,0 +1,48 @@ +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"] + + methods = ["GET"] + + parameters = { + "get": {}, + } + + auth = { + "get": False, + } + + 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] diff --git a/wikipack/version.py b/wikipack/version.py index 9ee900d3..be8b6b0b 100644 --- a/wikipack/version.py +++ b/wikipack/version.py @@ -1 +1 @@ -semantic = "0.1.0" +semantic = "1.0.0"