Skip to content

Commit c0ac7fc

Browse files
committed
implement history stats endpoint
1 parent 8d17843 commit c0ac7fc

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/rtbnext/endpoint/stats.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
from rtbnext.endpoint.profile import ProfileEntity
1414
from rtbnext.resource.base import Resource
1515
from rtbnext.resource.collectable import CollectableResource
16+
from rtbnext.resource.series import TimeSeriesResource
1617
from rtbnext.schema.stats import (
17-
DBStats, GlobalStats, ProfileStats, Scatter, ScatterItem, Top10, WealthStats, HistoryItem, History
18+
DBStats, GlobalStats, History, HistoryItem, ProfileStats, Scatter, ScatterItem, Top10,
19+
WealthStats
1820
)
1921

2022
HistoryPoint = TypedDict( "HistoryPoint", {
@@ -38,7 +40,7 @@ class StatsEndpoint( EndpointBase ):
3840

3941
def _point( self, point: HistoryItem ) -> HistoryPoint:
4042
"""Converts a raw history row into a typed history point."""
41-
43+
4244
date, count, total, woman, quote, change, percent = point
4345

4446
return {
@@ -78,6 +80,12 @@ def wealth( self ) -> Resource[ WealthStats ]:
7880

7981
return self._resource( "v2/stats/wealth.json" )
8082

83+
@property
84+
def history( self ) -> TimeSeriesResource[ History, HistoryPoint ]:
85+
"""Returns the historical stats time series resource."""
86+
87+
return self._series( "v2/stats/history.csv", point= self._point )
88+
8189
@property
8290
def top10( self ) -> Resource[ Top10 ]:
8391
"""Returns the top 10 billionaires list resource."""

0 commit comments

Comments
 (0)