Get optimization history.
(
self,
model_name: Optional[str] = None,
limit: int = 100
)
| 263 | conn.commit() |
| 264 | |
| 265 | def get_optimization_history( |
| 266 | self, |
| 267 | model_name: Optional[str] = None, |
| 268 | limit: int = 100 |
| 269 | ) -> List[Dict[str, Any]]: |
| 270 | """Get optimization history.""" |
| 271 | with sqlite3.connect(self.db_path) as conn: |
| 272 | cursor = conn.cursor() |
| 273 | |
| 274 | if model_name: |
| 275 | query = """ |
| 276 | SELECT * FROM optimization_history |
| 277 | WHERE model_name = ? |
| 278 | ORDER BY timestamp DESC |
| 279 | LIMIT ? |
| 280 | """ |
| 281 | cursor.execute(query, (model_name, limit)) |
| 282 | else: |
| 283 | query = """ |
| 284 | SELECT * FROM optimization_history |
| 285 | ORDER BY timestamp DESC |
| 286 | LIMIT ? |
| 287 | """ |
| 288 | cursor.execute(query, (limit,)) |
| 289 | |
| 290 | columns = [desc[0] for desc in cursor.description] |
| 291 | return [dict(zip(columns, row)) for row in cursor.fetchall()] |