[feat] solution/backend,frontend,postgres-init: 서비스 사이트 공개 화면 방문 수집 — 전체 방문 통계에 합산하고 사이트 표에 한 줄로, 기능 문서 추가
This commit is contained in:
1 parent
2fc50de161
commit
99a344f65c
21 files changed
+378
-21
No files matched your search
@@ -19,7 +19,10 @@ class IVisitCRUD(ABC):
|
||||
@abstractmethod
|
||||
async def stats(self, cdb: AsyncSession, start: datetime, end: datetime, today_since: datetime, site_id,
|
||||
overall: bool) -> Tuple[ErrorType, dict]:
|
||||
"""기간 [start, end) 집계 + today_since 이후 고유 방문자. 키: today·summary·daily·referrers·devices + (overall) sites | (사이트) pages·utm."""
|
||||
"""기간 [start, end) 집계 + today_since 이후 고유 방문자. 키: today·summary·daily·referrers·devices + (overall) sites·service_site | (사이트) pages·utm.
|
||||
|
||||
site_id 를 주면 그 사이트만, 없으면 발행 사이트와 서비스 사이트 공개 화면(site_id NULL)을 합쳐 센다.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -38,6 +41,7 @@ class VisitCRUD(IVisitCRUD):
|
||||
scope = v.deleted == False # noqa: E712
|
||||
if site_id is not None:
|
||||
scope = and_(scope, v.site_id == site_id)
|
||||
# 전체(site_id None)는 발행 사이트와 서비스 사이트를 합친다.
|
||||
where = and_(scope, v.created_at >= start, v.created_at < end)
|
||||
views = func.count().label("views")
|
||||
visitors = func.count(distinct(v.visitor_hash)).label("visitors")
|
||||
@@ -71,6 +75,8 @@ class VisitCRUD(IVisitCRUD):
|
||||
.order_by(func.count().desc())
|
||||
.limit(20)
|
||||
)
|
||||
# 서비스 사이트는 묶을 사업장이 없어 위 조인에서 빠진다 — 따로 세서 사이트 표에 한 줄로 끼운다.
|
||||
queries["service_site"] = select(views, visitors).where(where, v.site_id.is_(None))
|
||||
else:
|
||||
queries["pages"] = (
|
||||
select(v.path, views, visitors).where(where).group_by(v.path).order_by(func.count().desc()).limit(20)
|
||||
|
||||
Reference in new issue
Block a user