1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

publish: 5.7.8

This commit is contained in:
Steffo 2020-04-27 15:33:31 +02:00
parent 2d0d018ba5
commit f9f72c3c1a
5 changed files with 38 additions and 2 deletions

View file

@ -2,7 +2,7 @@
[tool.poetry] [tool.poetry]
name = "royalpack" name = "royalpack"
version = "5.7.7" version = "5.7.8"
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_diario_random import ApiDiarioRandomStar
from .api_polls_create import ApiPollsCreate from .api_polls_create import ApiPollsCreate
from .api_polls_get import ApiPollsGet from .api_polls_get import ApiPollsGet
from .api_polls_list import ApiPollsList from .api_polls_list import ApiPollsList
from .api_cvstats_latest import ApiCvstatsLatestStar
# 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 = [
ApiPollsCreate, ApiPollsCreate,
ApiPollsGet, ApiPollsGet,
ApiPollsList, ApiPollsList,
ApiCvstatsLatestStar,
] ]
# Don't change this, it should automatically generate __all__ # Don't change this, it should automatically generate __all__

View file

@ -0,0 +1,21 @@
import royalnet.utils as ru
from royalnet.backpack.tables import *
from royalnet.constellation.api import *
from ..tables import Cvstats
class ApiCvstatsLatestStar(ApiStar):
path = "/api/cvstats/latest/v1"
methods = ["GET"]
summary = "Get the latest 500 cvstats."
tags = ["cvstats"]
async def api(self, data: ApiData) -> ru.JSON:
CvstatsT = self.alchemy.get(Cvstats)
cvstats = data.session.query(CvstatsT).order_by(CvstatsT.timestamp.desc()).limit(500).all()
return list(map(lambda c: c.json(), cvstats))

View file

@ -45,3 +45,16 @@ class Cvstats:
@declared_attr @declared_attr
def users_total(self): def users_total(self):
return Column(Integer) return Column(Integer)
def json(self):
return {
"timestamp": self.timestamp.isoformat(),
"users_total": self.users_total,
"members_total": self.members_total,
"users_online": self.users_online,
"members_online": self.members_online,
"users_connected": self.users_connected,
"members_connected": self.members_connected,
"users_playing": self.users_playing,
"members_playing": self.members_playing,
}

View file

@ -1 +1 @@
semantic = "5.7.7" semantic = "5.7.8"