Comparing version 1.0.163 to 1.0.164
@@ -260,4 +260,51 @@ "use strict"; | ||
function create_deltas_cache(api) { | ||
var _this = this; | ||
var cache = (0, AgVueWrap_1.reactive)([]); | ||
function makeup(type, id, start, end) { | ||
var _this = this; | ||
cache.unshift({ type: type, id: id, start: start, end: end, deltas: [], _id: 0, value: undefined, index: 0 }); | ||
while (cache.length > 10) | ||
cache.pop(); | ||
var toupdate = cache[0]; | ||
(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var deltas, phrases; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
AgCounter_1.AgCounter.inc('update deltas_cache'); | ||
return [4 /*yield*/, api.hisData.deltas(type, id, start, end)]; | ||
case 1: | ||
deltas = _a.sent(); | ||
deltas.sort(function (a, b) { return a.time.getTime() - b.time.getTime(); }); | ||
phrases = []; | ||
deltas.forEach(function (delta) { | ||
if (delta.snapshot) { | ||
if (phrases.length > 0) | ||
phrases[phrases.length - 1].end = delta.time; | ||
var snapshot = delta.snapshot, rest = __rest(delta, ["snapshot"]); | ||
phrases.push({ | ||
_id: delta.time.getTime(), | ||
value: snapshot.value, | ||
index: 0, | ||
start: delta.time, | ||
end: delta.time, | ||
deltas: [rest] | ||
}); | ||
} | ||
else if (phrases.length > 0) { | ||
phrases[phrases.length - 1].end = delta.time; | ||
phrases[phrases.length - 1].deltas.push(delta); | ||
} | ||
}); | ||
if (phrases.length > 0) | ||
phrases[phrases.length - 1].end = end; | ||
// const target = phrases.find(v => time >= v.start && time < v.end) | ||
// // won't happen | ||
// if (!target) throw 'no target found' | ||
cache.splice.apply(cache, __spreadArray([cache.indexOf(toupdate), 1], phrases.map(function (v) { return (__assign(__assign({}, v), { type: type, id: id })); }), false)); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })(); | ||
return toupdate; | ||
} | ||
return { | ||
@@ -270,2 +317,7 @@ cache: cache, | ||
cache.unshift(cache.splice(i, 1)[0]); | ||
var ret = cache[0]; | ||
var end_1 = ret.end; | ||
if (end_1.getTime() - time.getTime() < 60 * 1000 && !cache.find(function (v) { return v.type === type && v.id === id && v.start === end_1; })) { | ||
makeup(type, id, end_1, AgHelper_1.AgHelper.offsetTime(end_1, 60 * 1000)); | ||
} | ||
return cache[0]; | ||
@@ -275,49 +327,36 @@ } | ||
var start = AgHelper_1.AgHelper.offsetTime(time, -60 * 1000); | ||
var end_1 = AgHelper_1.AgHelper.offsetTime(time, 60 * 1000); | ||
cache.unshift({ type: type, id: id, start: start, end: end_1, deltas: [], _id: 0, value: undefined, index: 0 }); | ||
while (cache.length > 10) | ||
cache.pop(); | ||
var toupdate_1 = cache[0]; | ||
(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var deltas, phrases, target; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
AgCounter_1.AgCounter.inc('update deltas_cache'); | ||
return [4 /*yield*/, api.hisData.deltas(toupdate_1.type, toupdate_1.id, toupdate_1.start, toupdate_1.end)]; | ||
case 1: | ||
deltas = _a.sent(); | ||
deltas.sort(function (a, b) { return a.time.getTime() - b.time.getTime(); }); | ||
phrases = []; | ||
deltas.forEach(function (delta) { | ||
if (delta.snapshot) { | ||
if (phrases.length > 0) | ||
phrases[phrases.length - 1].end = delta.time; | ||
var snapshot = delta.snapshot, rest = __rest(delta, ["snapshot"]); | ||
phrases.push({ | ||
_id: delta.time.getTime(), | ||
value: snapshot.value, | ||
index: 0, | ||
start: delta.time, | ||
end: delta.time, | ||
deltas: [rest] | ||
}); | ||
} | ||
else if (phrases.length > 0) { | ||
phrases[phrases.length - 1].end = delta.time; | ||
phrases[phrases.length - 1].deltas.push(delta); | ||
} | ||
}); | ||
if (phrases.length > 0) | ||
phrases[phrases.length - 1].end = end_1; | ||
target = phrases.find(function (v) { return time >= v.start && time < v.end; }); | ||
// won't happen | ||
if (!target) | ||
throw 'no target found'; | ||
cache.splice.apply(cache, __spreadArray([cache.indexOf(toupdate_1), 1], phrases.map(function (v) { return (__assign(__assign({}, v), { type: toupdate_1.type, id: toupdate_1.id })); }), false)); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })(); | ||
return toupdate_1; | ||
var end = AgHelper_1.AgHelper.offsetTime(time, 60 * 1000); | ||
return makeup(type, id, start, end); | ||
// cache.unshift({ type, id, start, end, deltas: [], _id: 0, value: undefined, index: 0 }); | ||
// while (cache.length > 10) cache.pop() | ||
// const toupdate = cache[0]; | ||
// (async () => { | ||
// AgCounter.inc('update deltas_cache') | ||
// const deltas = await api.hisData.deltas(toupdate.type, toupdate.id, toupdate.start, toupdate.end) | ||
// deltas.sort((a, b) => a.time.getTime() - b.time.getTime()) | ||
// const phrases = [] as TmPhrase[] | ||
// deltas.forEach(delta => { | ||
// if (delta.snapshot) { | ||
// if (phrases.length > 0) phrases[phrases.length - 1].end = delta.time | ||
// const { snapshot, ...rest } = delta | ||
// phrases.push({ | ||
// _id: delta.time.getTime(), | ||
// value: snapshot.value, | ||
// index: 0, | ||
// start: delta.time, | ||
// end: delta.time, | ||
// deltas: [rest] | ||
// }) | ||
// } else if (phrases.length > 0) { | ||
// phrases[phrases.length - 1].end = delta.time | ||
// phrases[phrases.length - 1].deltas.push(delta) | ||
// } | ||
// }) | ||
// if (phrases.length > 0) phrases[phrases.length - 1].end = end | ||
// const target = phrases.find(v => time >= v.start && time < v.end) | ||
// // won't happen | ||
// if (!target) throw 'no target found' | ||
// cache.splice(cache.indexOf(toupdate), 1, ...phrases.map(v => ({ ...v, type: toupdate.type, id: toupdate.id }))) | ||
// })() | ||
// return toupdate | ||
} | ||
@@ -343,3 +382,3 @@ } | ||
cache.pop(); | ||
var toupdate_2 = cache[0]; | ||
var toupdate_1 = cache[0]; | ||
(function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -351,4 +390,4 @@ var _a; | ||
AgCounter_1.AgCounter.inc('update frequence_cache'); | ||
_a = toupdate_2; | ||
return [4 /*yield*/, api.hisData.frequency(toupdate_2.type, toupdate_2.id, new Date(toupdate_2.date))]; | ||
_a = toupdate_1; | ||
return [4 /*yield*/, api.hisData.frequency(toupdate_1.type, toupdate_1.id, new Date(toupdate_1.date))]; | ||
case 1: | ||
@@ -360,3 +399,3 @@ _a.counts = (_b.sent()).counts; | ||
}); })(); | ||
return toupdate_2.counts; | ||
return toupdate_1.counts; | ||
} | ||
@@ -363,0 +402,0 @@ } |
{ | ||
"name": "ag-repo", | ||
"version": "1.0.163", | ||
"version": "1.0.164", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
163393
3651
0