Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
9dd0ef18
"...internal/pkg/git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "21a04332ec8e229fa66bcb70e7e6faa3df02ea0d"
Commit
9dd0ef18
authored
Jan 12, 2026
by
yangjianbo
Browse files
fix(仪表盘): 优化CleanupAggregates方法,逐条删除数据以提高错误处理能力
parent
18b8bd43
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/internal/repository/dashboard_aggregation_repo.go
View file @
9dd0ef18
...
@@ -83,13 +83,21 @@ func (r *dashboardAggregationRepository) UpdateAggregationWatermark(ctx context.
...
@@ -83,13 +83,21 @@ func (r *dashboardAggregationRepository) UpdateAggregationWatermark(ctx context.
}
}
func
(
r
*
dashboardAggregationRepository
)
CleanupAggregates
(
ctx
context
.
Context
,
hourlyCutoff
,
dailyCutoff
time
.
Time
)
error
{
func
(
r
*
dashboardAggregationRepository
)
CleanupAggregates
(
ctx
context
.
Context
,
hourlyCutoff
,
dailyCutoff
time
.
Time
)
error
{
_
,
err
:=
r
.
sql
.
ExecContext
(
ctx
,
`
hourlyCutoffUTC
:=
hourlyCutoff
.
UTC
()
DELETE FROM usage_dashboard_hourly WHERE bucket_start < $1;
dailyCutoffUTC
:=
dailyCutoff
.
UTC
()
DELETE FROM usage_dashboard_hourly_users WHERE bucket_start < $1;
if
_
,
err
:=
r
.
sql
.
ExecContext
(
ctx
,
"DELETE FROM usage_dashboard_hourly WHERE bucket_start < $1"
,
hourlyCutoffUTC
);
err
!=
nil
{
DELETE FROM usage_dashboard_daily WHERE bucket_date < $2::date;
DELETE FROM usage_dashboard_daily_users WHERE bucket_date < $2::date;
`
,
hourlyCutoff
.
UTC
(),
dailyCutoff
.
UTC
())
return
err
return
err
}
if
_
,
err
:=
r
.
sql
.
ExecContext
(
ctx
,
"DELETE FROM usage_dashboard_hourly_users WHERE bucket_start < $1"
,
hourlyCutoffUTC
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
r
.
sql
.
ExecContext
(
ctx
,
"DELETE FROM usage_dashboard_daily WHERE bucket_date < $1::date"
,
dailyCutoffUTC
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
r
.
sql
.
ExecContext
(
ctx
,
"DELETE FROM usage_dashboard_daily_users WHERE bucket_date < $1::date"
,
dailyCutoffUTC
);
err
!=
nil
{
return
err
}
return
nil
}
}
func
(
r
*
dashboardAggregationRepository
)
CleanupUsageLogs
(
ctx
context
.
Context
,
cutoff
time
.
Time
)
error
{
func
(
r
*
dashboardAggregationRepository
)
CleanupUsageLogs
(
ctx
context
.
Context
,
cutoff
time
.
Time
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment