支持自部署需求管理、交付流程与飞书集成
This commit is contained in:
1 parent
2149aeb6ed
commit
51a2e548f2
152 files changed
+8652
-6394
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import type { Demand } from './demand';
|
||||
|
||||
export type SavedDemandWrite = { version: number; demand: Demand };
|
||||
|
||||
/** Retain writes acknowledged after a GET began without dropping its other records. */
|
||||
export function mergeDemandSnapshot(
|
||||
snapshot: Demand[],
|
||||
writes: Iterable<SavedDemandWrite>,
|
||||
startedAtVersion: number,
|
||||
): Demand[] {
|
||||
const records = new Map(snapshot.map(demand => [demand.id, demand]));
|
||||
for (const { version, demand } of writes) {
|
||||
if (version <= startedAtVersion) continue;
|
||||
const serverRecord = records.get(demand.id);
|
||||
if (!serverRecord || serverRecord.revision <= demand.revision) records.set(demand.id, demand);
|
||||
}
|
||||
return [...records.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
||||
}
|
||||
Reference in new issue
Block a user