neoagent 2.0.4 → 2.0.5
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.
|
@@ -137,12 +137,30 @@ function ingestHealthSync(userId, body = {}) {
|
|
|
137
137
|
return ingestHealthSyncTx(userId, body);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
function hydrateRun(row) {
|
|
141
|
+
if (!row) return null;
|
|
142
|
+
return {
|
|
143
|
+
...row,
|
|
144
|
+
summary: (() => {
|
|
145
|
+
try { return JSON.parse(row.summary_json || '{}'); } catch { return {}; }
|
|
146
|
+
})(),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
140
150
|
function getHealthSyncStatus(userId) {
|
|
141
151
|
const lastRun = db.prepare(`
|
|
142
152
|
SELECT id, source, provider, sync_window_start, sync_window_end, record_count, summary_json, created_at
|
|
143
153
|
FROM health_sync_runs
|
|
144
154
|
WHERE user_id = ?
|
|
145
|
-
ORDER BY created_at DESC
|
|
155
|
+
ORDER BY created_at DESC, rowid DESC
|
|
156
|
+
LIMIT 1
|
|
157
|
+
`).get(userId);
|
|
158
|
+
|
|
159
|
+
const lastNonEmptyRun = db.prepare(`
|
|
160
|
+
SELECT id, source, provider, sync_window_start, sync_window_end, record_count, summary_json, created_at
|
|
161
|
+
FROM health_sync_runs
|
|
162
|
+
WHERE user_id = ? AND record_count > 0
|
|
163
|
+
ORDER BY created_at DESC, rowid DESC
|
|
146
164
|
LIMIT 1
|
|
147
165
|
`).get(userId);
|
|
148
166
|
|
|
@@ -155,12 +173,8 @@ function getHealthSyncStatus(userId) {
|
|
|
155
173
|
`).all(userId);
|
|
156
174
|
|
|
157
175
|
return {
|
|
158
|
-
lastRun: lastRun
|
|
159
|
-
|
|
160
|
-
summary: (() => {
|
|
161
|
-
try { return JSON.parse(lastRun.summary_json || '{}'); } catch { return {}; }
|
|
162
|
-
})(),
|
|
163
|
-
} : null,
|
|
176
|
+
lastRun: hydrateRun(lastRun),
|
|
177
|
+
lastNonEmptyRun: hydrateRun(lastNonEmptyRun),
|
|
164
178
|
metrics: metrics.map((metric) => ({
|
|
165
179
|
metricType: metric.metric_type,
|
|
166
180
|
sampleCount: Number(metric.sample_count || 0),
|