TakeBalanceSnapshots creates daily snapshots of balances in batches. It accepts an optional 'batch_size' query parameter to control the batch processing size. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad Request: If there's an error in the batch size p
(c *gin.Context)
| 365 | // - 400 Bad Request: If there's an error in the batch size parameter or during snapshot creation. |
| 366 | // - 200 OK: If the snapshots are successfully created, returns the total number of snapshots created. |
| 367 | func (a Api) TakeBalanceSnapshots(c *gin.Context) { |
| 368 | // Get batch size from query parameter, default to 1000 if not specified |
| 369 | batchSize, err := strconv.Atoi(c.DefaultQuery("batch_size", "1000")) |
| 370 | if err != nil || batchSize <= 0 { |
| 371 | c.JSON(http.StatusBadRequest, gin.H{"error": "invalid batch_size value"}) |
| 372 | return |
| 373 | } |
| 374 | |
| 375 | // Call the service to take snapshots |
| 376 | a.ledgerforge.TakeBalanceSnapshots(c.Request.Context(), batchSize) |
| 377 | |
| 378 | c.JSON(http.StatusOK, gin.H{ |
| 379 | "message": "Snapshotting in progress. should be completed shortly", |
| 380 | }) |
| 381 | } |
| 382 | |
| 383 | // GetBalanceAtTime retrieves a balance's state at a specific point in time. |
| 384 | // It extracts the balance ID from the route parameters and the timestamp from query parameters. |
nothing calls this directly
no test coverage detected