MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TakeBalanceSnapshots

Method TakeBalanceSnapshots

api/balance.go:367–381  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
367func (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.

Callers

nothing calls this directly

Calls 1

TakeBalanceSnapshotsMethod · 0.65

Tested by

no test coverage detected