@gentbajko/slopify 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,7 +56,15 @@ export function projectSelected(db, revision) {
|
|
|
56
56
|
for (const row of outputs)
|
|
57
57
|
insertOutput(db, row.output);
|
|
58
58
|
db.prepare("DELETE FROM stage_pieces WHERE stage_id IN (SELECT id FROM stages WHERE project_id=?)").run(revision.projectId);
|
|
59
|
-
|
|
59
|
+
// `stage_pieces` holds one row per stage, kind and position. When a rewrite gives work new
|
|
60
|
+
// keys (narration whose text changed, say), the pieces under the old keys stay selected in
|
|
61
|
+
// the revision while new ones are published into the same positions. The records come oldest
|
|
62
|
+
// first, so the newest claimant of each position is the one projected; the others remain in
|
|
63
|
+
// the revision's history.
|
|
64
|
+
const newest = new Map();
|
|
65
|
+
for (const row of pieces)
|
|
66
|
+
newest.set(`${row.piece.stageId}\0${row.piece.kind}\0${String(row.piece.idx)}`, row);
|
|
67
|
+
for (const row of newest.values()) {
|
|
60
68
|
const stage = db
|
|
61
69
|
.prepare("SELECT id FROM stages WHERE project_id=? AND kind=?")
|
|
62
70
|
.get(revision.projectId, row.stageKind);
|