used tags cache count fix

This commit is contained in:
julian 2024-06-06 14:36:21 -06:00
parent 85f609fa6f
commit 20f743932b
3 changed files with 7 additions and 7 deletions

View file

@ -50,7 +50,7 @@ abstract class FiroCacheCoordinator {
static Future<void> runFetchAndUpdateSparkUsedCoinTags( static Future<void> runFetchAndUpdateSparkUsedCoinTags(
ElectrumXClient client, ElectrumXClient client,
) async { ) async {
final count = await FiroCacheCoordinator.getUsedCoinTagsLastAddedRowId(); final count = await FiroCacheCoordinator.getUsedCoinTagsCount();
final unhashedTags = await client.getSparkUnhashedUsedCoinsTags( final unhashedTags = await client.getSparkUnhashedUsedCoinsTags(
startNumber: count, startNumber: count,
); );
@ -101,14 +101,14 @@ abstract class FiroCacheCoordinator {
/// Assuming the integrity of the data. Faster than actually calling count on /// Assuming the integrity of the data. Faster than actually calling count on
/// a table where no records have been deleted. None should be deleted from /// a table where no records have been deleted. None should be deleted from
/// this table in practice. /// this table in practice.
static Future<int> getUsedCoinTagsLastAddedRowId() async { static Future<int> getUsedCoinTagsCount() async {
final result = await _Reader._getUsedCoinTagsLastAddedRowId( final result = await _Reader._getUsedCoinTagsCount(
db: _FiroCache.usedTagsCacheDB, db: _FiroCache.usedTagsCacheDB,
); );
if (result.isEmpty) { if (result.isEmpty) {
return 0; return 0;
} }
return result.first["highestId"] as int? ?? 0; return result.first["count"] as int? ?? 0;
} }
static Future<bool> checkTagIsUsed( static Future<bool> checkTagIsUsed(

View file

@ -75,11 +75,11 @@ abstract class _Reader {
return db.select("$query;"); return db.select("$query;");
} }
static Future<ResultSet> _getUsedCoinTagsLastAddedRowId({ static Future<ResultSet> _getUsedCoinTagsCount({
required Database db, required Database db,
}) async { }) async {
const query = """ const query = """
SELECT MAX(id) AS highestId SELECT COUNT(*) AS count
FROM SparkUsedCoinTags; FROM SparkUsedCoinTags;
"""; """;

View file

@ -954,7 +954,7 @@ class ElectrumXClient {
Logging.instance.log( Logging.instance.log(
"Finished ElectrumXClient.getSparkUnhashedUsedCoinsTags(startNumber" "Finished ElectrumXClient.getSparkUnhashedUsedCoinsTags(startNumber"
"=$startNumber). " "=$startNumber). # of tags fetched=${tags.length}, "
"Duration=${DateTime.now().difference(start)}", "Duration=${DateTime.now().difference(start)}",
level: LogLevel.Info, level: LogLevel.Info,
); );