mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
fix(channel-monitor-v2): clear CI lint and align trend axis with range zoom
Fix golangci unused/gofmt on the gentle-backfill path. Plot matrix and line-chart X axes on the selected [requested_start, requested_end) window (empty slots while backfill lags), and let plain mouse-wheel zoom narrow the visible interval so pulse blocks grow wider.
This commit is contained in:
@@ -1019,6 +1019,7 @@ func (r *channelMonitorV2Repository) loadCoverage(ctx context.Context, filter se
|
||||
if !wm.HasData || wm.DataThrough.IsZero() || wm.LastSuccessfulAt.IsZero() {
|
||||
return &service.ChannelMonitorV2Coverage{
|
||||
RequestedStart: filter.Start,
|
||||
RequestedEnd: filter.End,
|
||||
CoverageStart: filter.End,
|
||||
DataThrough: filter.Start,
|
||||
ComputedAt: time.Time{},
|
||||
@@ -1053,6 +1054,7 @@ func (r *channelMonitorV2Repository) loadCoverage(ctx context.Context, filter se
|
||||
// minute-level lag would otherwise always show "partial historical coverage".
|
||||
return &service.ChannelMonitorV2Coverage{
|
||||
RequestedStart: filter.Start,
|
||||
RequestedEnd: filter.End,
|
||||
CoverageStart: coverageStart,
|
||||
DataThrough: through,
|
||||
ComputedAt: computedAt,
|
||||
|
||||
@@ -149,7 +149,11 @@ type ChannelMonitorV2HealthThresholds struct {
|
||||
}
|
||||
|
||||
type ChannelMonitorV2Coverage struct {
|
||||
RequestedStart time.Time `json:"requested_start"`
|
||||
RequestedStart time.Time `json:"requested_start"`
|
||||
// RequestedEnd is the exclusive upper bound of the UI-selected window
|
||||
// (filter.End). Charts/matrices should plot [RequestedStart, RequestedEnd)
|
||||
// even when CoverageStart is later (partial backfill).
|
||||
RequestedEnd time.Time `json:"requested_end"`
|
||||
CoverageStart time.Time `json:"coverage_start"`
|
||||
DataThrough time.Time `json:"data_through"`
|
||||
ComputedAt time.Time `json:"computed_at"`
|
||||
|
||||
@@ -15,9 +15,6 @@ const (
|
||||
// Retention walks back to the longest stored tier (1d rollup = 90d). Per-tier
|
||||
// prune in the repository drops short-lived 1m/user/hist facts earlier.
|
||||
channelMonitorV2RetentionMax = 90 * 24 * time.Hour
|
||||
// Product bootstrap goal: fill the UI ranges 90m / 24h / 7d / 30d first.
|
||||
// Banner hides once coveredFrom reaches this depth; 90d retention continues silently.
|
||||
channelMonitorV2BootstrapWindow = ChannelMonitorV2BootstrapProductWindow
|
||||
// First tick after upgrade prioritizes the default 90m view (with small padding).
|
||||
channelMonitorV2BootstrapFirst = 2 * time.Hour
|
||||
// Always refresh a small trailing window so late writes land without
|
||||
@@ -188,23 +185,6 @@ func (s *ChannelMonitorV2Aggregator) loop() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ChannelMonitorV2Aggregator) bootstrapActive() bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if !s.cursorLoaded {
|
||||
return true
|
||||
}
|
||||
if !s.hasAggregated {
|
||||
return true
|
||||
}
|
||||
if s.backfillFailures >= 3 {
|
||||
return false
|
||||
}
|
||||
now := time.Now().UTC().Truncate(time.Minute)
|
||||
target := now.Add(-channelMonitorV2BootstrapWindow)
|
||||
return s.backfillAt.IsZero() || s.backfillAt.After(target)
|
||||
}
|
||||
|
||||
func (s *ChannelMonitorV2Aggregator) passiveAggregationAllowed(ctx context.Context) bool {
|
||||
if s == nil || s.settings == nil {
|
||||
// Fail closed without settings: do not aggregate under ambiguous mode.
|
||||
|
||||
@@ -787,9 +787,9 @@ func (s *SettingService) parseSettings(settings map[string]string) *SystemSettin
|
||||
result.ChannelMonitorDefaultIntervalSeconds = parseChannelMonitorInterval(
|
||||
settings[SettingKeyChannelMonitorDefaultIntervalSeconds],
|
||||
)
|
||||
// 默认隐藏吞吐(迁移 206 的隐私默认):未配置时必须与 setting_public.go 的
|
||||
// 公开读取路径给出同一个值,否则管理端看到“未隐藏”而用户端实际已隐藏。
|
||||
result.ChannelMonitorHideThroughput = !isFalseSettingValue(settings[SettingKeyChannelMonitorHideThroughput])
|
||||
// 默认隐藏吞吐(迁移 206 的隐私默认):未配置时必须与 setting_public.go 的
|
||||
// 公开读取路径给出同一个值,否则管理端看到“未隐藏”而用户端实际已隐藏。
|
||||
result.ChannelMonitorHideThroughput = !isFalseSettingValue(settings[SettingKeyChannelMonitorHideThroughput])
|
||||
|
||||
// Available channels feature (default: disabled; strict true)
|
||||
result.AvailableChannelsEnabled = settings[SettingKeyAvailableChannelsEnabled] == "true"
|
||||
|
||||
Reference in New Issue
Block a user