Skip to content

Commit

Permalink
chore: display fixed fk error ids
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Nov 4, 2024
1 parent eda71d9 commit 509cf3d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions upstream/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"github.com/flanksource/commons/properties"
"github.com/flanksource/duty/api"
"github.com/flanksource/duty/context"
dutil "github.com/flanksource/duty/db"
Expand Down Expand Up @@ -52,6 +53,18 @@ type ForeignKeyErrorSummary struct {
IDs []string `json:"ids,omitempty"`
}

const FKErrorIDCount = 10

func (fks ForeignKeyErrorSummary) MarshalJSON() ([]byte, error) {
// Display less IDs to keep UI consistent
idLimit := properties.Int(FKErrorIDCount, "upstream.summary.fkerror_id_count")
fks.IDs = lo.Slice(fks.IDs, 0, idLimit)
if len(fks.IDs) >= idLimit {
fks.IDs = append(fks.IDs, "...")
}
return json.Marshal(fks)
}

type ReconcileTableSummary struct {
Success int `json:"success,omitempty"`
FKeyError ForeignKeyErrorSummary `json:"foreign_error,omitempty"`
Expand Down

0 comments on commit 509cf3d

Please sign in to comment.