MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / get_platform_stats

Method get_platform_stats

astrbot/core/db/sqlite.py:180–195  ·  view source on GitHub ↗

Get platform statistics within the specified offset in seconds and group by platform_id.

(self, offset_sec: int = 86400)

Source from the content-addressed store, hash-verified

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."""
182 async with self.get_db() as session:
183 session: AsyncSession
184 now = datetime.now()
185 start_time = now - timedelta(seconds=offset_sec)
186 result = await session.execute(
187 text("""
188 SELECT * FROM platform_stats
189 WHERE timestamp >= :start_time
190 GROUP BY platform_id
191 ORDER BY timestamp DESC
192 """),
193 {"start_time": start_time},
194 )
195 return list(result.scalars().all())
196
197 async def insert_provider_stat(
198 self,

Callers

nothing calls this directly

Calls 6

nowMethod · 0.80
allMethod · 0.80
scalarsMethod · 0.80
listFunction · 0.50
get_dbMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected