odstranenie odohranych kol za den zo statistik
This commit is contained in:
1 parent
18ae869ee8
commit
115413a813
3 files changed
+2
-18
No files matched your search
+2
-15
@@ -12,7 +12,7 @@ from sqlalchemy import extract, func, or_, select
|
||||
from user_agents import parse as parse_ua
|
||||
|
||||
from db.db import async_session
|
||||
from db.models import Game, Guess, PageView, Player
|
||||
from db.models import Game, PageView, Player
|
||||
|
||||
# Konvencia na rozpoznanie botieho uctu (viz api.bots.BOT_PREFIX) -- drzana tu
|
||||
# lokalne, aby sa do statistickej cesty netahala rl vrstva (siet/numpy).
|
||||
@@ -190,7 +190,7 @@ async def _login_event_counts(session, column, exclude_empty=False) -> list:
|
||||
async def get_daily_stats(logged_in_only: bool = False) -> dict:
|
||||
"""logged_in_only obmedzuje traffic-analyticke widgety (PageView) na
|
||||
zaznamy z eventu "login" (jediny event, ktory nesie player_id -- bezne
|
||||
beacony ho neposielaju vobec). Herne metriky (games/players/rounds) su
|
||||
beacony ho neposielaju vobec). Herne metriky (games/players) su
|
||||
uz zo svojej podstaty vzdy o prihlasenych uctoch, prepinac sa ich netyka.
|
||||
top_paths ostava vzdy pocitane zo vsetkych navstev bez ohladu na scope --
|
||||
najnavstevovanejsie stranky maju zmysel len ako celok."""
|
||||
@@ -269,18 +269,6 @@ async def get_daily_stats(logged_in_only: bool = False) -> dict:
|
||||
)
|
||||
).all()
|
||||
|
||||
rday = func.date(Game.created_at)
|
||||
rounds_rows = (
|
||||
await session.execute(
|
||||
select(rday.label("day"), func.count().label("n"))
|
||||
.select_from(Guess)
|
||||
.join(Game, Guess.game_id == Game.id)
|
||||
.group_by(rday)
|
||||
.order_by(rday.desc())
|
||||
.limit(_DAYS_WINDOW)
|
||||
)
|
||||
).all()
|
||||
|
||||
vday = func.date(PageView.created_at)
|
||||
pageview_q = select(vday.label("day"), func.count().label("n"))
|
||||
if logged_in_only:
|
||||
@@ -354,7 +342,6 @@ async def get_daily_stats(logged_in_only: bool = False) -> dict:
|
||||
"total_players": total_players,
|
||||
"unconfirmed_players": unconfirmed_players,
|
||||
"peak_hours": {int(r.h): r.n for r in peak_hours},
|
||||
"rounds_per_day": {str(r.day): r.n for r in rounds_rows},
|
||||
"pageviews_per_day": {str(r.day): r.n for r in pageview_rows},
|
||||
"visitors_per_day": {str(r.day): r.n for r in visitor_rows},
|
||||
"pageviews_per_day_by_device": pageviews_per_day_by_device,
|
||||
|
||||
@@ -23,7 +23,6 @@ interface DailyStats {
|
||||
total_players: number;
|
||||
unconfirmed_players: number;
|
||||
peak_hours: Record<string, number>;
|
||||
rounds_per_day: Record<string, number>;
|
||||
pageviews_per_day: Record<string, number>;
|
||||
visitors_per_day: Record<string, number>;
|
||||
pageviews_per_day_by_device: Record<string, Record<string, number>>;
|
||||
@@ -169,7 +168,6 @@ export default function AdminStats() {
|
||||
<div className={`grid gap-4 ${desktop ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
<TimeSeriesChart title="Hry za deň" data={data.games_per_day} />
|
||||
<TimeSeriesChart title="Nové registrácie za deň" data={data.players_per_day} />
|
||||
<TimeSeriesChart title="Odohrané kolá za deň" data={data.rounds_per_day} />
|
||||
<TimeSeriesChart title="Hodiny s najvyššou aktivitou" data={data.peak_hours} kind="bar" />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -351,7 +351,6 @@ class StatsCase(unittest.TestCase):
|
||||
self.assertEqual(data["finished_bot_games"], base_bot_games + 1)
|
||||
self.assertEqual(data["finished_human_games"], base_human_games)
|
||||
self.assertGreaterEqual(sum(data["games_per_day"].values()), 1)
|
||||
self.assertGreaterEqual(sum(data["rounds_per_day"].values()), 4)
|
||||
|
||||
def test_unconfirmed_players_counted_separately(self):
|
||||
before = run(stats.get_daily_stats())
|
||||
|
||||
Reference in new issue
Block a user