@yarkivaev/scada 2.6.20 → 2.6.22
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.
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ export async function classifierClaim(pool,machine,{workId,workToken,from,until,
|
|
|
9
9
|
const row=result.rows[0];
|
|
10
10
|
const stored=row && (row.cursor_ms===null?null:Number(row.cursor_ms));
|
|
11
11
|
const bound=row && (row.end_ms===null?null:Number(row.end_ms));
|
|
12
|
-
if(!row || Number(row.from_ms)
|
|
12
|
+
if(!row || Number(row.from_ms)>from || Number(row.until_ms)<until || stored!==cursor || (end!==null && bound!==end)){
|
|
13
13
|
const error=new Error('History work claim changed');error.statusCode=409;throw error;
|
|
14
14
|
}
|
|
15
15
|
return row;
|
|
@@ -24,6 +24,7 @@ export default async function historyContext(pool,machine,from,until,{padding,cu
|
|
|
24
24
|
const range = { from,until,paddingMs:padding,cursor,end:envelope,...(classifierKey && {classifierKey}),...(timeScale!==1 && {timeScale}),...(workId && {workId,workToken}) };
|
|
25
25
|
if ((cursor !== null && !Number.isSafeInteger(cursor)) || (envelope !== null && !Number.isSafeInteger(envelope))) { throw new TypeError('Invalid history cursor'); }
|
|
26
26
|
const claim=await classifierClaim(pool,machine,{workId,workToken,from,until,cursor,end:envelope});
|
|
27
|
+
if(claim){range.from=Number(claim.from_ms);range.until=Number(claim.until_ms);}
|
|
27
28
|
const held=claim && envelope===null && claim.end_ms!==null ? Number(claim.end_ms) : envelope;
|
|
28
29
|
if (held!==null && envelope===null) { range.end=held; }
|
|
29
30
|
if (from<cutoff && !claim) {
|
|
@@ -67,5 +68,5 @@ export default async function historyContext(pool,machine,from,until,{padding,cu
|
|
|
67
68
|
const last = observations.items.at(-1)?.time;
|
|
68
69
|
const rightClosed = next === null && last !== undefined && segments.rows.some((row) => { return row.duration>0 && new Date(row.end_time).getTime()*timeScale>=last; });
|
|
69
70
|
const snapshot = { page,initial,...(classifierKey && {classifierSeed:classifier}),annotations:annotations.rows,segments:segments.rows,...observations,rightClosed };
|
|
70
|
-
return { ...snapshot,available:true,revision:historyRevision(snapshot, until, timeScale),context:range };
|
|
71
|
+
return { ...snapshot,available:true,revision:historyRevision(snapshot, range.until, timeScale),context:range };
|
|
71
72
|
}
|