Collect stats on pubkeys with more than 3 events

This commit is contained in:
Kieran 2024-02-02 22:33:32 +00:00
parent 5964a20f9e
commit 9ba3fc118d
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -28,22 +28,26 @@ public class PubkeyStatsService : BackgroundService
allKeys.Add(k);
}
_logger.LogInformation("Collected pubkeys in: {n:#,##0}ms", sw.Elapsed.TotalMilliseconds);
_logger.LogInformation("Collected {count:#,##0} pubkeys in: {n:#,##0}ms", allKeys.Count, sw.Elapsed.TotalMilliseconds);
sw.Restart();
foreach (var pk in allKeys)
{
var stat = new PubKeyStat
var evs = await _store.CountUserEvents(pk);
if (evs > 3)
{
PubKey = Convert.FromHexString(pk),
LastUpdate = DateTime.UtcNow,
TotalEvents = await _store.CountUserEvents(pk)
};
var stat = new PubKeyStat
{
PubKey = Convert.FromHexString(pk),
LastUpdate = DateTime.UtcNow,
TotalEvents = evs
};
results.Add(stat);
results.Add(stat);
}
}
_logger.LogInformation("Computed pubkey stats in: {n:#,##0}ms", sw.Elapsed.TotalMilliseconds);
_logger.LogInformation("Computed {count:#,##0} pubkey stats in: {n:#,##0}ms", results.Count, sw.Elapsed.TotalMilliseconds);
await _store.StorePubkeyStats(results);
}