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

Method LoadReconciliationProgress

database/reconciliation.go:703–722  ·  view source on GitHub ↗

LoadReconciliationProgress retrieves the progress of a reconciliation process from the database. If the reconciliation progress is not found, it returns an empty ReconciliationProgress object. Parameters: - ctx: Context for managing the request and tracing. - reconciliationID: The ID of the reconcil

(ctx context.Context, reconciliationID string)

Source from the content-addressed store, hash-verified

701// Returns:
702// - A ReconciliationProgress object containing the current progress, or an error wrapped in an APIError if any issues occur.
703func (d Datasource) LoadReconciliationProgress(ctx context.Context, reconciliationID string) (model.ReconciliationProgress, error) {
704 ctx, span := otel.Tracer("reconciliation.database").Start(ctx, "Loading reconciliation progress from db")
705 defer span.End()
706
707 var progress model.ReconciliationProgress
708 err := d.Conn.QueryRowContext(ctx, `
709 SELECT processed_count, last_processed_external_txn_id
710 FROM ledgerforge.reconciliation_progress
711 WHERE reconciliation_id = $1
712 `, reconciliationID).Scan(&progress.ProcessedCount, &progress.LastProcessedExternalTxnID)
713 // Handle potential errors
714 if err != nil {
715 if err == sql.ErrNoRows {
716 return model.ReconciliationProgress{}, nil // Return empty progress if not found
717 }
718 return model.ReconciliationProgress{}, apierror.NewAPIError(apierror.ErrInternalServer, "Failed to load reconciliation progress", err)
719 }
720
721 return progress, nil
722}
723
724// FetchAndGroupExternalTransactions retrieves external transactions from the database based on a specific grouping criterion and paginates the results.
725// The function first checks if the results are available in cache, and if not, fetches the data from the database, groups it by the specified criterion, and stores the result in cache.

Calls 2

NewAPIErrorFunction · 0.92
StartMethod · 0.45