Fix tail rows in portrait generation

This commit is contained in:
2026-05-25 10:06:40 +02:00
parent 01ddcf8735
commit e6fffdf041
4 changed files with 24 additions and 7 deletions
+15 -2
View File
@@ -48,6 +48,7 @@ type nativeCollectedDataset struct {
LockData map[string]int
RetiredKeys map[string]struct{}
TableKey string
DenseRowMax int
LockAdded int
LockPruned int
LockModified bool
@@ -370,7 +371,7 @@ func buildNativeUnchecked(p *project.Project, opts NativeBuildOptions, progress
if err != nil {
return BuildResult{}, err
}
if err := write2DA(compiled, filepath.Join(output2DA, dataset.Dataset.OutputName), dataset.Dataset.Kind == nativeDatasetBase); err != nil {
if err := write2DA(compiled, filepath.Join(output2DA, dataset.Dataset.OutputName), dataset.Dataset.Kind == nativeDatasetBase, dataset.DenseRowMax); err != nil {
return BuildResult{}, err
}
}
@@ -1228,6 +1229,7 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
Rows: rows,
LockData: lockData,
RetiredKeys: retiredKeys,
DenseRowMax: baseBoundaryID,
LockAdded: lockAdded,
LockPruned: lockPruned,
LockModified: lockModified,
@@ -5181,7 +5183,7 @@ func normalizeCollectedSpellImpactScripts(rows []map[string]any, baseRowKeys map
}
}
func write2DA(data map[string]any, path string, denseRows bool) error {
func write2DA(data map[string]any, path string, denseRows bool, denseRowMax int) error {
columns, ok := data["columns"].([]string)
if !ok {
return fmt.Errorf("2da columns must be []string")
@@ -5223,6 +5225,17 @@ func write2DA(data map[string]any, path string, denseRows bool) error {
nextID = rowID + 1
}
}
if denseRows {
for nextID <= denseRowMax {
builder.WriteString(strconv.Itoa(nextID))
for range columns {
builder.WriteByte('\t')
builder.WriteString(nullValue)
}
builder.WriteByte('\n')
nextID++
}
}
return os.WriteFile(path, []byte(builder.String()), 0o644)
}