diff --git a/backend/src/api/mining.ts b/backend/src/api/mining.ts index 2e094229b..afcc89220 100644 --- a/backend/src/api/mining.ts +++ b/backend/src/api/mining.ts @@ -93,8 +93,11 @@ class Mining { const indexedTimestamp = await HashratesRepository.$getWeeklyHashrateTimestamps(); const hashrates: any[] = []; const genesisTimestamp = 1231006505; // bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f - const lastMidnight = this.getDateMidnight(new Date()); - let toTimestamp = Math.round((lastMidnight.getTime() - 604800) / 1000); + + const now = new Date(); + const lastMonday = new Date(now.setDate(now.getDate() - (now.getDay() + 6) % 7)); + const lastMondayMidnight = this.getDateMidnight(lastMonday); + let toTimestamp = Math.round((lastMondayMidnight.getTime() - 604800) / 1000); const totalWeekIndexed = (await BlocksRepository.$blockCount(null, null)) / 1008; let indexedThisRun = 0; @@ -142,7 +145,7 @@ class Mining { hashrates.length = 0; const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt)); - if (elapsedSeconds > 5) { + if (elapsedSeconds > 1) { const weeksPerSeconds = (indexedThisRun / elapsedSeconds).toFixed(2); const formattedDate = new Date(fromTimestamp * 1000).toUTCString(); const weeksLeft = Math.round(totalWeekIndexed - totalIndexed); @@ -228,7 +231,7 @@ class Mining { } const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt)); - if (elapsedSeconds > 5) { + if (elapsedSeconds > 1) { const daysPerSeconds = (indexedThisRun / elapsedSeconds).toFixed(2); const formattedDate = new Date(fromTimestamp * 1000).toUTCString(); const daysLeft = Math.round(totalDayIndexed - totalIndexed); diff --git a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts index 582dee263..67b4fd233 100644 --- a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts +++ b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.ts @@ -182,8 +182,9 @@ export class HashrateChartComponent implements OnInit { difficulty = Math.round(data[1].data[1] / difficultyPowerOfTen.divider); } + const date = new Date(data[0].data[0]).toLocaleDateString(this.locale, { year: 'numeric', month: 'short', day: 'numeric' }); return ` - ${data[0].axisValueLabel}
+ ${date}
${data[0].marker} ${data[0].seriesName}: ${formatNumber(hashrate, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s
${data[1].marker} ${data[1].seriesName}: ${formatNumber(difficulty, this.locale, '1.2-2')} ${difficultyPowerOfTen.unit} `; diff --git a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts index 016f7a319..0e79a21dd 100644 --- a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts +++ b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts @@ -160,7 +160,8 @@ export class HashrateChartPoolsComponent implements OnInit { }, borderColor: '#000', formatter: function (data) { - let tooltip = `${data[0].axisValueLabel}
`; + const date = new Date(data[0].data[0]).toLocaleDateString(this.locale, { year: 'numeric', month: 'short', day: 'numeric' }); + let tooltip = `${date}
`; data.sort((a, b) => b.data[1] - a.data[1]); for (const pool of data) { if (pool.data[1] > 0) {