Count the number of platform statistics records.
(self)
| 166 | ) |
| 167 | |
| 168 | async def count_platform_stats(self) -> int: |
| 169 | """Count the number of platform statistics records.""" |
| 170 | async with self.get_db() as session: |
| 171 | session: AsyncSession |
| 172 | result = await session.execute( |
| 173 | select(func.count(col(PlatformStat.platform_id))).select_from( |
| 174 | PlatformStat, |
| 175 | ), |
| 176 | ) |
| 177 | count = result.scalar_one_or_none() |
| 178 | return count if count is not None else 0 |
| 179 | |
| 180 | async def get_platform_stats(self, offset_sec: int = 86400) -> list[PlatformStat]: |
| 181 | """Get platform statistics within the specified offset in seconds and group by platform_id.""" |