forge-openclaw-plugin 0.3.1 → 0.3.2
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.
|
@@ -50,15 +50,18 @@ export async function syncDevrageMetricHistory(options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
export async function syncDevrageMetricHistoryIfNeeded() {
|
|
52
52
|
const state = getDevrageSyncState();
|
|
53
|
-
const nextSync = getNextDevrageMetricSync(state);
|
|
53
|
+
const nextSync = getNextDevrageMetricSync(state, new Date(), needsDevrageCumulativeRageBackfill());
|
|
54
54
|
if (nextSync) {
|
|
55
55
|
await syncDevrageMetricHistory(nextSync);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
export function getNextDevrageMetricSync(state, now = new Date()) {
|
|
58
|
+
export function getNextDevrageMetricSync(state, now = new Date(), needsCumulativeRageBackfill = false) {
|
|
59
59
|
if (!state?.full_sync_completed_at) {
|
|
60
60
|
return { forceFull: true };
|
|
61
61
|
}
|
|
62
|
+
if (needsCumulativeRageBackfill) {
|
|
63
|
+
return { forceFull: true };
|
|
64
|
+
}
|
|
62
65
|
const today = todayDateKey(now);
|
|
63
66
|
if (state.last_synced_date_key !== today) {
|
|
64
67
|
return { dateKey: today };
|
|
@@ -72,6 +75,22 @@ export function getNextDevrageMetricSync(state, now = new Date()) {
|
|
|
72
75
|
}
|
|
73
76
|
return null;
|
|
74
77
|
}
|
|
78
|
+
export function needsDevrageCumulativeRageBackfill() {
|
|
79
|
+
const rows = getDatabase()
|
|
80
|
+
.prepare(`SELECT metric_key, COUNT(*) AS count
|
|
81
|
+
FROM psyche_devrage_metric_measures
|
|
82
|
+
WHERE metric_key IN (?, ?, ?, ?)
|
|
83
|
+
GROUP BY metric_key`)
|
|
84
|
+
.all(SWEAR_COUNT_KEY, SWEARING_MESSAGE_PERCENT_KEY, AVERAGE_MAX_CUMULATIVE_RAGE_KEY, MAX_CUMULATIVE_RAGE_KEY);
|
|
85
|
+
const counts = new Map(rows.map((row) => [row.metric_key, Number(row.count) || 0]));
|
|
86
|
+
const legacyRows = (counts.get(SWEAR_COUNT_KEY) ?? 0) > 0 ||
|
|
87
|
+
(counts.get(SWEARING_MESSAGE_PERCENT_KEY) ?? 0) > 0;
|
|
88
|
+
if (!legacyRows) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return ((counts.get(AVERAGE_MAX_CUMULATIVE_RAGE_KEY) ?? 0) === 0 ||
|
|
92
|
+
(counts.get(MAX_CUMULATIVE_RAGE_KEY) ?? 0) === 0);
|
|
93
|
+
}
|
|
75
94
|
export function getDevrageMetricPayload() {
|
|
76
95
|
const generatedAt = nowIso();
|
|
77
96
|
const state = getDevrageSyncState();
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "forge-openclaw-plugin",
|
|
3
3
|
"name": "Forge",
|
|
4
4
|
"description": "Curated OpenClaw adapter for the Forge collaboration API, UI entrypoint, and localhost auto-start runtime.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.2",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/package.json
CHANGED