Merge pull request #2331 from mempool/nymkappa/bugfix/stats-timestamp

Use timestamp instead of date in stats tables
This commit is contained in:
wiz 2022-08-20 00:11:46 +09:00 committed by GitHub
commit b2d07d2d44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -4,7 +4,7 @@ import logger from '../logger';
import { Common } from './common'; import { Common } from './common';
class DatabaseMigration { class DatabaseMigration {
private static currentVersion = 37; private static currentVersion = 38;
private queryTimeout = 120000; private queryTimeout = 120000;
private statisticsAddedIndexed = false; private statisticsAddedIndexed = false;
private uniqueLogs: string[] = []; private uniqueLogs: string[] = [];
@ -328,6 +328,16 @@ class DatabaseMigration {
if (databaseSchemaVersion < 37 && isBitcoin == true) { if (databaseSchemaVersion < 37 && isBitcoin == true) {
await this.$executeQuery(this.getCreateLNNodesSocketsTableQuery(), await this.$checkIfTableExists('nodes_sockets')); await this.$executeQuery(this.getCreateLNNodesSocketsTableQuery(), await this.$checkIfTableExists('nodes_sockets'));
} }
if (databaseSchemaVersion < 38 && isBitcoin == true) {
if (config.LIGHTNING.ENABLED) {
this.uniqueLog(logger.notice, `'lightning_stats' and 'node_stats' tables have been truncated.`);
}
await this.$executeQuery(`TRUNCATE lightning_stats`);
await this.$executeQuery(`TRUNCATE node_stats`);
await this.$executeQuery('ALTER TABLE `lightning_stats` CHANGE `added` `added` timestamp NULL');
await this.$executeQuery('ALTER TABLE `node_stats` CHANGE `added` `added` timestamp NULL');
}
} }
/** /**

View file

@ -272,10 +272,12 @@ class LightningStatsImporter {
// Stats exist already, don't calculate/insert them // Stats exist already, don't calculate/insert them
if (existingStatsTimestamps[timestamp] !== undefined) { if (existingStatsTimestamps[timestamp] !== undefined) {
totalProcessed++;
continue; continue;
} }
if (filename.indexOf('topology_') === -1) { if (filename.indexOf('topology_') === -1) {
totalProcessed++;
continue; continue;
} }