mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-12 17:15:37 +00:00
fix: Several coderabbit suggestions on next branch
This commit is contained in:
@@ -126,12 +126,16 @@ async function fetchActionLogs() {
|
|||||||
const args = {
|
const args = {
|
||||||
"actionId": actionId,
|
"actionId": actionId,
|
||||||
"startOffset": BigInt(startOffset),
|
"startOffset": BigInt(startOffset),
|
||||||
|
"pageSize": BigInt(Number(pageSize.value)),
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await window.client.getActionLogs(args)
|
const response = await window.client.getActionLogs(args)
|
||||||
|
|
||||||
logs.value = response.logs
|
logs.value = response.logs
|
||||||
pageSize.value = Number(response.pageSize) || 0
|
const serverPageSize = Number(response.pageSize)
|
||||||
|
if (Number.isFinite(serverPageSize) && serverPageSize > 0) {
|
||||||
|
pageSize.value = serverPageSize
|
||||||
|
}
|
||||||
totalCount.value = Number(response.totalCount) || 0
|
totalCount.value = Number(response.totalCount) || 0
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to fetch action logs:', err)
|
console.error('Failed to fetch action logs:', err)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ func UserFromContext[T any](ctx context.Context, req *connect.Request[T], cfg *c
|
|||||||
return &user
|
return &user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gocyclo:ignore
|
||||||
func userFromHeaders[T any](req *connect.Request[T], cfg *config.Config) AuthenticatedUser {
|
func userFromHeaders[T any](req *connect.Request[T], cfg *config.Config) AuthenticatedUser {
|
||||||
var u AuthenticatedUser
|
var u AuthenticatedUser
|
||||||
if req == nil {
|
if req == nil {
|
||||||
@@ -234,6 +235,7 @@ func userFromHeaders[T any](req *connect.Request[T], cfg *config.Config) Authent
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gocyclo:ignore
|
||||||
func userFromLocalSession[T any](req *connect.Request[T], cfg *config.Config, u AuthenticatedUser) AuthenticatedUser {
|
func userFromLocalSession[T any](req *connect.Request[T], cfg *config.Config, u AuthenticatedUser) AuthenticatedUser {
|
||||||
if req == nil || u.Username != "" {
|
if req == nil || u.Username != "" {
|
||||||
return u
|
return u
|
||||||
|
|||||||
@@ -481,10 +481,16 @@ func (api *oliveTinAPI) GetActionLogs(ctx ctx.Context, req *connect.Request[apiv
|
|||||||
ret.StartOffset = page.start
|
ret.StartOffset = page.start
|
||||||
return connect.NewResponse(ret), nil
|
return connect.NewResponse(ret), nil
|
||||||
}
|
}
|
||||||
for _, le := range filtered[page.start:page.end] {
|
// Newest-first slicing: compute reversed indices
|
||||||
|
startIdx := page.total - page.end
|
||||||
|
endIdx := page.total - page.start
|
||||||
|
if startIdx < 0 { startIdx = 0 }
|
||||||
|
if endIdx > int64(len(filtered)) { endIdx = int64(len(filtered)) }
|
||||||
|
for _, le := range filtered[startIdx:endIdx] {
|
||||||
ret.Logs = append(ret.Logs, api.internalLogEntryToPb(le, user))
|
ret.Logs = append(ret.Logs, api.internalLogEntryToPb(le, user))
|
||||||
}
|
}
|
||||||
ret.CountRemaining = page.total - page.end
|
// Entries older than the returned newest page
|
||||||
|
ret.CountRemaining = page.start
|
||||||
ret.PageSize = page.size
|
ret.PageSize = page.size
|
||||||
ret.TotalCount = page.total
|
ret.TotalCount = page.total
|
||||||
ret.StartOffset = page.start
|
ret.StartOffset = page.start
|
||||||
|
|||||||
@@ -294,17 +294,20 @@ func overrideSimple(base *Config, overlay *Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func overrideNested(base *Config, overlay *Config) {
|
func overrideNested(base *Config, overlay *Config) {
|
||||||
if overlay.DefaultPolicy.ShowDiagnostics != base.DefaultPolicy.ShowDiagnostics {
|
// Only apply overrides when overlay explicitly enables the option.
|
||||||
base.DefaultPolicy.ShowDiagnostics = overlay.DefaultPolicy.ShowDiagnostics
|
// This mirrors the presence-check pattern used elsewhere to avoid
|
||||||
|
// unintentionally disabling an already-enabled base setting with a default false.
|
||||||
|
if overlay.DefaultPolicy.ShowDiagnostics {
|
||||||
|
base.DefaultPolicy.ShowDiagnostics = true
|
||||||
}
|
}
|
||||||
if overlay.DefaultPolicy.ShowLogList != base.DefaultPolicy.ShowLogList {
|
if overlay.DefaultPolicy.ShowLogList {
|
||||||
base.DefaultPolicy.ShowLogList = overlay.DefaultPolicy.ShowLogList
|
base.DefaultPolicy.ShowLogList = true
|
||||||
}
|
}
|
||||||
if overlay.Prometheus.Enabled != base.Prometheus.Enabled {
|
if overlay.Prometheus.Enabled {
|
||||||
base.Prometheus.Enabled = overlay.Prometheus.Enabled
|
base.Prometheus.Enabled = true
|
||||||
}
|
}
|
||||||
if overlay.Prometheus.DefaultGoMetrics != base.Prometheus.DefaultGoMetrics {
|
if overlay.Prometheus.DefaultGoMetrics {
|
||||||
base.Prometheus.DefaultGoMetrics = overlay.Prometheus.DefaultGoMetrics
|
base.Prometheus.DefaultGoMetrics = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user