Skip to content

Commit a38e612

Browse files
committed
build: 4.0.6
1 parent d58ee6a commit a38e612

6 files changed

Lines changed: 31 additions & 29 deletions

File tree

‎.goreleaser.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,13 @@ release:
144144
replace_existing_draft: true
145145
# 发布说明
146146
header: |
147-
## NodePassDash Release Notes (v4.0.5)
147+
## NodePassDash Release Notes (v4.0.6)
148148
149-
### Optimize
150-
- Refactor PostgreSQL database connection logic
149+
### Fix
150+
- repair hourly traffic statistics across SQLite and PostgreSQL
151+
152+
### Feature
153+
- endpoint page add update config menu
151154
152155
footer: |
153156

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**Language:** English | [简体中文](docs/zh-CN/README.md)
66

7-
![Version](https://img.shields.io/badge/version-4.0.5-blue.svg)
7+
![Version](https://img.shields.io/badge/version-4.0.6-blue.svg)
88
![GitHub license](https://img.shields.io/github/license/NodePassProject/NodePassDash)
99
![GitHub downloads](https://img.shields.io/github/downloads/NodePassProject/nodepassdash/total.svg)
1010
![Docker Pulls](https://img.shields.io/badge/docker_pulls-18k+-blue?logo=docker&logoColor=white)

‎cmd/server/main.go‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"time"
2828

2929
"github.com/gin-gonic/gin"
30-
"github.com/joho/godotenv"
3130
"github.com/glebarez/sqlite"
31+
"github.com/joho/godotenv"
3232
"gorm.io/gorm"
3333
)
3434

@@ -372,12 +372,7 @@ func startBackgroundServices(gormDB *gorm.DB, sseService *sse.Service, sseManage
372372
// 启动SSE相关服务
373373
go func() {
374374
sseManager.StartDaemon()
375-
376-
// 初始化SSE系统
377-
if err := sseManager.InitializeSystem(); err != nil {
378-
log.Errorf("初始化SSE系统失败: %v", err)
379-
}
380-
log.Info("SSE系统已启动")
375+
log.Info("SSE守护进程已启动")
381376
}()
382377

383378
// 启动WebSocket服务

‎internal/dashboard/traffic_service.go‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,17 @@ func (s *TrafficService) AggregateTrafficDataForHour(hourStart time.Time) error
8888
1 as record_count,
8989
CURRENT_TIMESTAMP,
9090
CURRENT_TIMESTAMP
91-
FROM service_history sh
92-
INNER JOIN (
91+
FROM (
9392
SELECT
94-
endpoint_id,
95-
instance_id,
96-
MAX(record_time) as max_record_time
97-
FROM service_history
98-
WHERE record_time >= ? AND record_time < ?
99-
GROUP BY endpoint_id, instance_id
100-
) latest ON sh.endpoint_id = latest.endpoint_id
101-
AND sh.instance_id = latest.instance_id
102-
AND sh.record_time = latest.max_record_time
103-
WHERE sh.record_time >= ? AND sh.record_time < ?
93+
sh.*,
94+
ROW_NUMBER() OVER (
95+
PARTITION BY sh.endpoint_id, sh.instance_id
96+
ORDER BY sh.record_time DESC, sh.id DESC
97+
) AS row_num
98+
FROM service_history sh
99+
WHERE sh.record_time >= ? AND sh.record_time < ?
100+
) sh
101+
WHERE sh.row_num = 1
104102
ON CONFLICT(hour_time, endpoint_id, instance_id) DO UPDATE SET
105103
tcp_rx_total = excluded.tcp_rx_total,
106104
tcp_tx_total = excluded.tcp_tx_total,
@@ -112,7 +110,7 @@ func (s *TrafficService) AggregateTrafficDataForHour(hourStart time.Time) error
112110
udp_tx_increment = excluded.udp_tx_increment,
113111
record_count = excluded.record_count,
114112
updated_at = CURRENT_TIMESTAMP`,
115-
hourStart, hourStart, hourEnd, hourStart, hourEnd).Error; err != nil {
113+
hourStart, hourStart, hourEnd).Error; err != nil {
116114
return fmt.Errorf("插入汇总数据失败: %v", err)
117115
}
118116

‎internal/dashboard/traffic_service_test.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
5757
EndpointID: 2, InstanceID: "b", RecordTime: hourStart.Add(59 * time.Minute).UTC(),
5858
DeltaTCPIn: 30, DeltaTCPOut: 1_200_000_000,
5959
},
60+
{
61+
// Duplicate latest timestamps are possible when an SSE event is
62+
// dispatched more than once. The higher ID must win deterministically.
63+
EndpointID: 1, InstanceID: "a", RecordTime: hourStart.Add(59 * time.Minute).UTC(),
64+
DeltaTCPIn: 25, DeltaTCPOut: 2_900_000_000,
65+
},
6066
}
6167
if err := db.Create(&history).Error; err != nil {
6268
t.Fatalf("insert service history: %v", err)
@@ -81,8 +87,8 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
8187
if !summary.HourTime.Equal(hourStart.UTC()) {
8288
t.Fatalf("hour time = %s, want %s", summary.HourTime, hourStart.UTC())
8389
}
84-
if summary.TCPTxTotal != 4_000_000_000 {
85-
t.Fatalf("tcp tx total = %d, want 4000000000", summary.TCPTxTotal)
90+
if summary.TCPTxTotal != 4_100_000_000 {
91+
t.Fatalf("tcp tx total = %d, want 4100000000", summary.TCPTxTotal)
8692
}
8793
if summary.InstanceCount != 2 {
8894
t.Fatalf("instance count = %d, want 2", summary.InstanceCount)
@@ -92,8 +98,8 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
9298
if err := db.Where("instance_id = ?", "a").First(&instanceA).Error; err != nil {
9399
t.Fatalf("load instance a summary: %v", err)
94100
}
95-
if instanceA.TCPTxIncrement != 300_000_000 {
96-
t.Fatalf("tcp tx increment = %d, want 300000000", instanceA.TCPTxIncrement)
101+
if instanceA.TCPTxIncrement != 400_000_000 {
102+
t.Fatalf("tcp tx increment = %d, want 400000000", instanceA.TCPTxIncrement)
97103
}
98104
}
99105

‎web/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "NodePassDash",
33
"private": true,
4-
"version": "4.0.5",
4+
"version": "4.0.6",
55
"packageManager": "pnpm@10.23.0",
66
"type": "module",
77
"scripts": {

0 commit comments

Comments
 (0)