Increment video generation count with daily reset
(self, token_id: int)
| 1249 | await db.commit() |
| 1250 | |
| 1251 | async def increment_video_count(self, token_id: int): |
| 1252 | """Increment video generation count with daily reset""" |
| 1253 | async with self._connect(write=True) as db: |
| 1254 | today = self._current_stats_date() |
| 1255 | # Get current stats |
| 1256 | cursor = await db.execute("SELECT today_date FROM token_stats WHERE token_id = ?", (token_id,)) |
| 1257 | row = await cursor.fetchone() |
| 1258 | |
| 1259 | # If date changed, reset all daily counters before recording today's video usage. |
| 1260 | if row and row[0] != today: |
| 1261 | await db.execute(""" |
| 1262 | UPDATE token_stats |
| 1263 | SET video_count = video_count + 1, |
| 1264 | today_image_count = 0, |
| 1265 | today_video_count = 1, |
| 1266 | today_error_count = 0, |
| 1267 | today_date = ? |
| 1268 | WHERE token_id = ? |
| 1269 | """, (today, token_id)) |
| 1270 | else: |
| 1271 | # Same day, just increment both |
| 1272 | await db.execute(""" |
| 1273 | UPDATE token_stats |
| 1274 | SET video_count = video_count + 1, |
| 1275 | today_video_count = today_video_count + 1, |
| 1276 | today_date = ? |
| 1277 | WHERE token_id = ? |
| 1278 | """, (today, token_id)) |
| 1279 | await db.commit() |
| 1280 | |
| 1281 | async def increment_error_count(self, token_id: int): |
| 1282 | """Increment error count with daily reset |