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

Function dbHasData

internal/search/reindex.go:427–461  ·  view source on GitHub ↗
(ctx context.Context, ds database.IDataSource)

Source from the content-addressed store, hash-verified

425}
426
427func dbHasData(ctx context.Context, ds database.IDataSource) bool {
428 ledgers, err := ds.GetAllLedgers(2, 0)
429 if err != nil {
430 logrus.WithError(err).Debug("could not check ledgers for reindex")
431 return false
432 }
433 if len(ledgers) > 1 {
434 return true
435 }
436
437 txns, err := ds.GetAllTransactions(ctx, 1, 0)
438 if err != nil {
439 logrus.WithError(err).Debug("could not check transactions for reindex")
440 return false
441 }
442 if len(txns) > 0 {
443 return true
444 }
445
446 balances, err := ds.GetAllBalances(1, 0)
447 if err != nil {
448 logrus.WithError(err).Debug("could not check balances for reindex")
449 return false
450 }
451 if len(balances) > 0 {
452 return true
453 }
454
455 identities, err := ds.GetAllIdentitiesPaginated(1, 0)
456 if err != nil {
457 logrus.WithError(err).Debug("could not check identities for reindex")
458 return false
459 }
460 return len(identities) > 0
461}
462
463func typesenseHasData(ctx context.Context, client *TypesenseClient) bool {
464 resp, err := client.Client.Collection(CollectionTransactions).Retrieve(ctx)

Callers 1

shouldReindexFunction · 0.85

Calls 5

GetAllLedgersMethod · 0.65
GetAllTransactionsMethod · 0.65
GetAllBalancesMethod · 0.65
DebugMethod · 0.45

Tested by

no test coverage detected