Increment image generation count with daily reset
(self, token_id: int)
| 1219 | return None |
| 1220 | |
| 1221 | async def increment_image_count(self, token_id: int): |
| 1222 | """Increment image generation count with daily reset""" |
| 1223 | async with self._connect(write=True) as db: |
| 1224 | today = self._current_stats_date() |
| 1225 | # Get current stats |
| 1226 | cursor = await db.execute("SELECT today_date FROM token_stats WHERE token_id = ?", (token_id,)) |
| 1227 | row = await cursor.fetchone() |
| 1228 | |
| 1229 | # If date changed, reset all daily counters before recording today's image usage. |
| 1230 | if row and row[0] != today: |
| 1231 | await db.execute(""" |
| 1232 | UPDATE token_stats |
| 1233 | SET image_count = image_count + 1, |
| 1234 | today_image_count = 1, |
| 1235 | today_video_count = 0, |
| 1236 | today_error_count = 0, |
| 1237 | today_date = ? |
| 1238 | WHERE token_id = ? |
| 1239 | """, (today, token_id)) |
| 1240 | else: |
| 1241 | # Same day, just increment both |
| 1242 | await db.execute(""" |
| 1243 | UPDATE token_stats |
| 1244 | SET image_count = image_count + 1, |
| 1245 | today_image_count = today_image_count + 1, |
| 1246 | today_date = ? |
| 1247 | WHERE token_id = ? |
| 1248 | """, (today, token_id)) |
| 1249 | await db.commit() |
| 1250 | |
| 1251 | async def increment_video_count(self, token_id: int): |
| 1252 | """Increment video generation count with daily reset""" |
no test coverage detected