@bitcobblers/wod-wiki-wql 0.6.31 → 0.6.36
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/dist/index.cjs +251 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -42
- package/dist/index.d.ts +90 -42
- package/dist/index.mjs +249 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var WQL_CALC_TARGETS = [
|
|
|
53
53
|
"calc.sends"
|
|
54
54
|
];
|
|
55
55
|
var WQL_INTENSITY_TIERS = ["low", "moderate", "high"];
|
|
56
|
-
var WQL_GRAINS = ["
|
|
56
|
+
var WQL_GRAINS = ["summary", "event"];
|
|
57
57
|
var WQL_FIND_TARGETS = ["note", "block", "effort"];
|
|
58
58
|
var WQL_SCOPES = ["journal", "collections", "feeds", "all"];
|
|
59
59
|
var WQL_CONTENT_FILTER_KEYS = ["type", "text", "has", "source", "catalog", ...WQL_TAG_KEYS];
|
|
@@ -314,9 +314,20 @@ function parseRowsQuery(raw) {
|
|
|
314
314
|
return result;
|
|
315
315
|
}
|
|
316
316
|
result.filters = extractFilters(tree.topNode, synthetic);
|
|
317
|
+
const grainError = retiredGrainRollup(result.filters);
|
|
318
|
+
if (grainError) {
|
|
319
|
+
result.error = grainError;
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
317
322
|
}
|
|
318
323
|
return result;
|
|
319
324
|
}
|
|
325
|
+
function retiredGrainRollup(filters) {
|
|
326
|
+
if (filters.some((f) => f.key === "grain" && f.values.some((v) => v.value === "rollup"))) {
|
|
327
|
+
return "grain:rollup is retired \u2014 rollup grains are never stored; compute them with the .rollup suffix";
|
|
328
|
+
}
|
|
329
|
+
return void 0;
|
|
330
|
+
}
|
|
320
331
|
function extractFilters(query, text) {
|
|
321
332
|
const out = [];
|
|
322
333
|
const filters = query.getChild(Filters);
|
|
@@ -385,6 +396,11 @@ function parseAnalyticsQuery(raw) {
|
|
|
385
396
|
base.agg = aggText;
|
|
386
397
|
base.metric = text.slice(metricNode.from, metricNode.to);
|
|
387
398
|
base.filters = extractFilters(query, text);
|
|
399
|
+
const grainError = retiredGrainRollup(base.filters);
|
|
400
|
+
if (grainError) {
|
|
401
|
+
base.error = grainError;
|
|
402
|
+
return base;
|
|
403
|
+
}
|
|
388
404
|
if (whereText) {
|
|
389
405
|
const join = parseJoinClause(whereText);
|
|
390
406
|
if (join.error) {
|
|
@@ -436,6 +452,11 @@ function parseFindQuery(raw) {
|
|
|
436
452
|
}
|
|
437
453
|
result.target = text.slice(metricNode.from, metricNode.to);
|
|
438
454
|
result.filters = extractFilters(query, text);
|
|
455
|
+
const findGrainError = retiredGrainRollup(result.filters);
|
|
456
|
+
if (findGrainError) {
|
|
457
|
+
result.error = findGrainError;
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
439
460
|
if (whereText) {
|
|
440
461
|
const join = parseJoinClause(whereText);
|
|
441
462
|
if (join.error) {
|
|
@@ -721,9 +742,8 @@ function readGroupTags(metadata) {
|
|
|
721
742
|
const entries = Object.entries(tags).filter((pair) => typeof pair[1] === "string" && pair[1].length > 0).sort(([a], [b]) => a < b ? -1 : 1);
|
|
722
743
|
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
723
744
|
}
|
|
724
|
-
function
|
|
725
|
-
const
|
|
726
|
-
const rowsByKey = /* @__PURE__ */ new Map();
|
|
745
|
+
function foldSummaryOutputs(logs) {
|
|
746
|
+
const folded = /* @__PURE__ */ new Map();
|
|
727
747
|
for (const output of logs) {
|
|
728
748
|
if (output.outputType !== "analytics") continue;
|
|
729
749
|
const label = output.metrics.find((m) => m.type === MetricType.Label);
|
|
@@ -738,32 +758,171 @@ function normalizeSummaryFacts(logs, identity) {
|
|
|
738
758
|
const grade = metadataString(value.metadata, "grade");
|
|
739
759
|
const groupTags = readGroupTags(value.metadata) ?? (effortSlug ? { effort: effortSlug } : void 0);
|
|
740
760
|
const rowKey = groupTags ? `${metricKey}:${Object.entries(groupTags).map(([k, v]) => `${k}=${v}`).join(":")}` : metricKey;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
blockContentId: identity.blockContentId,
|
|
745
|
-
origin: identity.origin,
|
|
746
|
-
pageId: identity.pageId,
|
|
747
|
-
grain: "summary",
|
|
748
|
-
segmentId: identity.segmentId ?? "",
|
|
749
|
-
segmentVersion: identity.segmentVersion ?? 0,
|
|
750
|
-
resultId: identity.resultId,
|
|
751
|
-
type: metricKey,
|
|
761
|
+
folded.set(rowKey, {
|
|
762
|
+
projectionName,
|
|
763
|
+
metricKey,
|
|
752
764
|
value: value.value,
|
|
753
765
|
unit: value.unit,
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
...grade ? { grade } : {},
|
|
762
|
-
timestamp: identity.workoutTimestamp ?? output.timeSpan?.started ?? now,
|
|
763
|
-
createdAt: now
|
|
766
|
+
effortSlug,
|
|
767
|
+
discipline,
|
|
768
|
+
intensityTier,
|
|
769
|
+
grade,
|
|
770
|
+
groupTags,
|
|
771
|
+
rowKey,
|
|
772
|
+
started: output.timeSpan?.started
|
|
764
773
|
});
|
|
765
774
|
}
|
|
766
|
-
return
|
|
775
|
+
return folded;
|
|
776
|
+
}
|
|
777
|
+
function normalizeSummaryFacts(logs, identity) {
|
|
778
|
+
const now = Date.now();
|
|
779
|
+
return Array.from(foldSummaryOutputs(logs).values(), (f) => ({
|
|
780
|
+
id: `${identity.resultId}-${f.rowKey}-${now}`,
|
|
781
|
+
noteId: identity.noteId,
|
|
782
|
+
blockContentId: identity.blockContentId,
|
|
783
|
+
origin: identity.origin,
|
|
784
|
+
pageId: identity.pageId,
|
|
785
|
+
grain: "summary",
|
|
786
|
+
segmentId: identity.segmentId ?? "",
|
|
787
|
+
segmentVersion: identity.segmentVersion ?? 0,
|
|
788
|
+
resultId: identity.resultId,
|
|
789
|
+
type: f.metricKey,
|
|
790
|
+
value: f.value,
|
|
791
|
+
unit: f.unit,
|
|
792
|
+
label: f.projectionName,
|
|
793
|
+
metricKey: f.metricKey,
|
|
794
|
+
metricLabel: f.projectionName,
|
|
795
|
+
metricUnit: f.unit,
|
|
796
|
+
...f.effortSlug ? { effortSlug: f.effortSlug } : {},
|
|
797
|
+
...f.discipline ? { discipline: f.discipline } : {},
|
|
798
|
+
...f.intensityTier ? { intensityTier: f.intensityTier } : {},
|
|
799
|
+
...f.grade ? { grade: f.grade } : {},
|
|
800
|
+
timestamp: identity.workoutTimestamp ?? f.started ?? now,
|
|
801
|
+
createdAt: now
|
|
802
|
+
}));
|
|
803
|
+
}
|
|
804
|
+
function firstEffortSlug(metrics) {
|
|
805
|
+
const loose = metrics;
|
|
806
|
+
for (const m of loose) {
|
|
807
|
+
const slug = metadataString(m.metadata, "effortSlug");
|
|
808
|
+
if (slug) return slug;
|
|
809
|
+
}
|
|
810
|
+
return void 0;
|
|
811
|
+
}
|
|
812
|
+
function toEventRows(logs, identity) {
|
|
813
|
+
return logs.map((output, seq) => ({
|
|
814
|
+
id: `${identity.resultId}:${seq}`,
|
|
815
|
+
resultId: identity.resultId,
|
|
816
|
+
noteId: identity.noteId,
|
|
817
|
+
blockContentId: identity.blockContentId,
|
|
818
|
+
pageId: identity.pageId,
|
|
819
|
+
origin: identity.origin,
|
|
820
|
+
timestamp: identity.workoutTimestamp ?? output.timeSpan?.started ?? Date.now(),
|
|
821
|
+
grain: "event",
|
|
822
|
+
outputType: output.outputType ?? "segment",
|
|
823
|
+
effortSlug: firstEffortSlug(output.metrics),
|
|
824
|
+
metrics: output.metrics,
|
|
825
|
+
timeSpan: output.timeSpan?.started !== void 0 ? { started: output.timeSpan.started, ended: output.timeSpan.ended } : void 0,
|
|
826
|
+
sourceBlockKey: output.sourceBlockKey,
|
|
827
|
+
stackLevel: output.stackLevel,
|
|
828
|
+
completionReason: output.completionReason,
|
|
829
|
+
segmentId: identity.segmentId,
|
|
830
|
+
segmentVersion: identity.segmentVersion
|
|
831
|
+
}));
|
|
832
|
+
}
|
|
833
|
+
function toSummaryEventRows(logs, identity) {
|
|
834
|
+
const now = Date.now();
|
|
835
|
+
return Array.from(foldSummaryOutputs(logs).values(), (f) => ({
|
|
836
|
+
id: `${identity.resultId}:summary:${f.rowKey}`,
|
|
837
|
+
resultId: identity.resultId,
|
|
838
|
+
noteId: identity.noteId,
|
|
839
|
+
blockContentId: identity.blockContentId,
|
|
840
|
+
pageId: identity.pageId,
|
|
841
|
+
origin: identity.origin,
|
|
842
|
+
timestamp: identity.workoutTimestamp ?? f.started ?? now,
|
|
843
|
+
grain: "summary",
|
|
844
|
+
outputType: "analytics",
|
|
845
|
+
effortSlug: f.effortSlug,
|
|
846
|
+
metrics: [{
|
|
847
|
+
type: f.metricKey,
|
|
848
|
+
value: f.value,
|
|
849
|
+
...f.unit ? { unit: f.unit } : {},
|
|
850
|
+
metadata: {
|
|
851
|
+
canonicalKey: f.metricKey,
|
|
852
|
+
...f.effortSlug ? { effortSlug: f.effortSlug } : {},
|
|
853
|
+
...f.discipline ? { effortDiscipline: f.discipline } : {},
|
|
854
|
+
...f.intensityTier ? { effortIntensityTier: f.intensityTier } : {},
|
|
855
|
+
...f.groupTags ? { groupTags: f.groupTags } : {},
|
|
856
|
+
...f.grade ? { grade: f.grade } : {}
|
|
857
|
+
}
|
|
858
|
+
}],
|
|
859
|
+
segmentId: identity.segmentId,
|
|
860
|
+
segmentVersion: identity.segmentVersion
|
|
861
|
+
}));
|
|
862
|
+
}
|
|
863
|
+
function projectEventToFacts(record) {
|
|
864
|
+
const metrics = record.metrics;
|
|
865
|
+
if (record.grain === "summary") {
|
|
866
|
+
const m = metrics[0];
|
|
867
|
+
if (!m || typeof m.value !== "number") return [];
|
|
868
|
+
const metricKey = metadataString(m.metadata, "canonicalKey") ?? (m.type ?? "");
|
|
869
|
+
return [{
|
|
870
|
+
id: `${record.id}:0`,
|
|
871
|
+
noteId: record.noteId,
|
|
872
|
+
blockContentId: record.blockContentId,
|
|
873
|
+
origin: record.origin,
|
|
874
|
+
pageId: record.pageId,
|
|
875
|
+
grain: "summary",
|
|
876
|
+
segmentId: record.segmentId ?? "",
|
|
877
|
+
segmentVersion: record.segmentVersion ?? 0,
|
|
878
|
+
resultId: record.resultId,
|
|
879
|
+
type: metricKey,
|
|
880
|
+
value: m.value,
|
|
881
|
+
unit: m.unit,
|
|
882
|
+
label: metricKey,
|
|
883
|
+
metricKey,
|
|
884
|
+
metricLabel: metricKey,
|
|
885
|
+
metricUnit: m.unit,
|
|
886
|
+
effortSlug: metadataString(m.metadata, "effortSlug") ?? record.effortSlug,
|
|
887
|
+
discipline: metadataString(m.metadata, "effortDiscipline"),
|
|
888
|
+
intensityTier: metadataString(m.metadata, "effortIntensityTier"),
|
|
889
|
+
grade: metadataString(m.metadata, "grade"),
|
|
890
|
+
timestamp: record.timestamp,
|
|
891
|
+
createdAt: record.timestamp
|
|
892
|
+
}];
|
|
893
|
+
}
|
|
894
|
+
const label = metrics.find((m) => m.type === MetricType.Label);
|
|
895
|
+
const labelName = label ? String(label.value ?? label.image ?? "") : "";
|
|
896
|
+
const facts = [];
|
|
897
|
+
metrics.forEach((m) => {
|
|
898
|
+
if (m.type === MetricType.Label || typeof m.value !== "number") return;
|
|
899
|
+
const metricKey = metadataString(m.metadata, "canonicalKey") ?? (labelName ? resolveCanonicalMetricKey(labelName) : m.type ?? "metric");
|
|
900
|
+
const ordinal = facts.length;
|
|
901
|
+
facts.push({
|
|
902
|
+
id: `${record.id}:${ordinal}`,
|
|
903
|
+
noteId: record.noteId,
|
|
904
|
+
blockContentId: record.blockContentId,
|
|
905
|
+
origin: record.origin,
|
|
906
|
+
pageId: record.pageId,
|
|
907
|
+
grain: "event",
|
|
908
|
+
segmentId: record.segmentId ?? "",
|
|
909
|
+
segmentVersion: record.segmentVersion ?? 0,
|
|
910
|
+
resultId: record.resultId,
|
|
911
|
+
type: metricKey,
|
|
912
|
+
value: m.value,
|
|
913
|
+
unit: m.unit,
|
|
914
|
+
label: labelName || metricKey,
|
|
915
|
+
metricKey,
|
|
916
|
+
metricLabel: labelName || metricKey,
|
|
917
|
+
metricUnit: m.unit,
|
|
918
|
+
effortSlug: metadataString(m.metadata, "effortSlug") ?? record.effortSlug,
|
|
919
|
+
intensityTier: metadataString(m.metadata, "effortIntensityTier"),
|
|
920
|
+
grade: metadataString(m.metadata, "grade"),
|
|
921
|
+
timestamp: record.timestamp,
|
|
922
|
+
createdAt: record.timestamp
|
|
923
|
+
});
|
|
924
|
+
});
|
|
925
|
+
return facts;
|
|
767
926
|
}
|
|
768
927
|
|
|
769
928
|
// src/dashboard/frontmatter.ts
|
|
@@ -955,23 +1114,27 @@ function windowAnchor(selected, parsed, options2) {
|
|
|
955
1114
|
if (options2.anchor === "latest-activity" && parsed.last) return latestActivity(selected);
|
|
956
1115
|
return void 0;
|
|
957
1116
|
}
|
|
958
|
-
var
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1117
|
+
var defaultEventStore = {
|
|
1118
|
+
getEventsByTimeRange: async () => [],
|
|
1119
|
+
getEventsByResult: async () => [],
|
|
1120
|
+
getEventsForNote: async () => [],
|
|
1121
|
+
getEventsByContent: async () => [],
|
|
1122
|
+
scanAll: async () => [],
|
|
1123
|
+
appendEvents: async () => {
|
|
1124
|
+
},
|
|
1125
|
+
finalizeSummaries: async () => {
|
|
1126
|
+
},
|
|
1127
|
+
deleteEvents: async () => {
|
|
1128
|
+
}
|
|
962
1129
|
};
|
|
963
1130
|
var defaultNoteStore = {
|
|
964
1131
|
getAllNotes: async () => [],
|
|
965
|
-
getNoteIdsForTag: async () => /* @__PURE__ */ new Set()
|
|
1132
|
+
getNoteIdsForTag: async () => /* @__PURE__ */ new Set(),
|
|
1133
|
+
getNoteTagLabels: async () => []
|
|
966
1134
|
};
|
|
967
1135
|
var defaultBlockStore = {
|
|
968
1136
|
getAllBlocks: async () => []
|
|
969
1137
|
};
|
|
970
|
-
var defaultResultStore = {
|
|
971
|
-
getResultsByContentId: async () => [],
|
|
972
|
-
getResultById: async () => void 0,
|
|
973
|
-
getResultsForNote: async () => []
|
|
974
|
-
};
|
|
975
1138
|
var defaultEffortStore = {
|
|
976
1139
|
getAllEfforts: async () => []
|
|
977
1140
|
};
|
|
@@ -1083,32 +1246,31 @@ var QueryService = class {
|
|
|
1083
1246
|
store;
|
|
1084
1247
|
noteStore;
|
|
1085
1248
|
blockStore;
|
|
1086
|
-
resultStore;
|
|
1087
1249
|
effortStore;
|
|
1088
1250
|
staticNoteStore;
|
|
1089
1251
|
staticBlockStore;
|
|
1090
|
-
constructor(
|
|
1091
|
-
if (
|
|
1092
|
-
const stores =
|
|
1093
|
-
this.store = stores.
|
|
1252
|
+
constructor(storesOrEventStore, noteStore, blockStore, effortStore, staticNoteStore, staticBlockStore) {
|
|
1253
|
+
if (storesOrEventStore && typeof storesOrEventStore === "object" && ("eventStore" in storesOrEventStore || "noteStore" in storesOrEventStore || "blockStore" in storesOrEventStore || "effortStore" in storesOrEventStore || "staticNoteStore" in storesOrEventStore || "staticBlockStore" in storesOrEventStore)) {
|
|
1254
|
+
const stores = storesOrEventStore;
|
|
1255
|
+
this.store = stores.eventStore ?? defaultEventStore;
|
|
1094
1256
|
this.noteStore = stores.noteStore ?? defaultNoteStore;
|
|
1095
1257
|
this.blockStore = stores.blockStore ?? defaultBlockStore;
|
|
1096
|
-
this.resultStore = stores.resultStore ?? defaultResultStore;
|
|
1097
1258
|
this.effortStore = stores.effortStore ?? defaultEffortStore;
|
|
1098
1259
|
this.staticNoteStore = stores.staticNoteStore;
|
|
1099
1260
|
this.staticBlockStore = stores.staticBlockStore;
|
|
1100
1261
|
} else {
|
|
1101
|
-
this.store =
|
|
1262
|
+
this.store = storesOrEventStore ?? defaultEventStore;
|
|
1102
1263
|
this.noteStore = noteStore ?? defaultNoteStore;
|
|
1103
1264
|
this.blockStore = blockStore ?? defaultBlockStore;
|
|
1104
|
-
this.resultStore = resultStore ?? defaultResultStore;
|
|
1105
1265
|
this.effortStore = effortStore ?? defaultEffortStore;
|
|
1106
1266
|
this.staticNoteStore = staticNoteStore;
|
|
1107
1267
|
this.staticBlockStore = staticBlockStore;
|
|
1108
1268
|
}
|
|
1109
1269
|
}
|
|
1270
|
+
/** Windowed flat-fact fetch — the projected view over the event store. */
|
|
1110
1271
|
async getFactsByTimeRange(start, end) {
|
|
1111
|
-
|
|
1272
|
+
const rows = await this.store.getEventsByTimeRange(start, end);
|
|
1273
|
+
return rows.flatMap(projectEventToFacts);
|
|
1112
1274
|
}
|
|
1113
1275
|
async runQuery(raw, options2 = {}) {
|
|
1114
1276
|
const parsed = parseQuery(raw);
|
|
@@ -1132,8 +1294,8 @@ var QueryService = class {
|
|
|
1132
1294
|
}
|
|
1133
1295
|
/**
|
|
1134
1296
|
* Execute a rows query (rows:{…}, #949) — the session results table plane.
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1297
|
+
* Reads event rows directly over the unified store (ticket 003): no
|
|
1298
|
+
* WorkoutResult blob parsing; outputType narrowing hits the promoted column.
|
|
1137
1299
|
*/
|
|
1138
1300
|
async runRows(parsed, options2 = {}) {
|
|
1139
1301
|
const empty = { parsed, runs: [] };
|
|
@@ -1155,28 +1317,30 @@ var QueryService = class {
|
|
|
1155
1317
|
if (resultIds.length + blockIds.length + noteIds.length === 0) {
|
|
1156
1318
|
return { ...empty, error: "Rows query needs a scope: result:, block:, or note:." };
|
|
1157
1319
|
}
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1166
|
-
for (const
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
let
|
|
1320
|
+
const byResult = /* @__PURE__ */ new Map();
|
|
1321
|
+
const collect = (rows) => {
|
|
1322
|
+
for (const row of rows) {
|
|
1323
|
+
const bucket = byResult.get(row.resultId);
|
|
1324
|
+
if (bucket) bucket.push(row);
|
|
1325
|
+
else byResult.set(row.resultId, [row]);
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
for (const id of resultIds) collect(await this.store.getEventsByResult(id));
|
|
1329
|
+
for (const blockContentId of blockIds) collect(await this.store.getEventsByContent(blockContentId));
|
|
1330
|
+
for (const noteId of noteIds) collect(await this.store.getEventsForNote(noteId));
|
|
1331
|
+
let groups = [...byResult.entries()].filter(([, rows]) => rows.length > 0);
|
|
1170
1332
|
if (parsed.last) {
|
|
1171
|
-
|
|
1172
|
-
(
|
|
1333
|
+
groups = groups.filter(
|
|
1334
|
+
([, rows]) => effectiveTimeWindow(rows[0].timestamp, parsed.last, void 0, options2.anchorNow)
|
|
1173
1335
|
);
|
|
1174
1336
|
}
|
|
1175
|
-
|
|
1176
|
-
const runs =
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1337
|
+
groups.sort((a, b) => b[1][0].timestamp - a[1][0].timestamp);
|
|
1338
|
+
const runs = groups.map(([resultId, rows]) => ({
|
|
1339
|
+
resultId,
|
|
1340
|
+
noteId: rows[0].noteId,
|
|
1341
|
+
timestamp: rows[0].timestamp,
|
|
1342
|
+
events: parsed.outputType ? rows.filter((row) => row.outputType === parsed.outputType) : rows
|
|
1343
|
+
})).filter((run) => run.events.length > 0);
|
|
1180
1344
|
return { parsed, runs };
|
|
1181
1345
|
}
|
|
1182
1346
|
/**
|
|
@@ -1365,14 +1529,11 @@ var QueryService = class {
|
|
|
1365
1529
|
};
|
|
1366
1530
|
if (parsed.error) return empty;
|
|
1367
1531
|
if (parsed.join) return this.runJoined(parsed, options2);
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
const inRange = new Set((await this.store.getFactsByTimeRange(start, end)).map((row) => row.id));
|
|
1374
|
-
candidates = candidates.filter((row) => inRange.has(row.id));
|
|
1375
|
-
}
|
|
1532
|
+
const windowed = options2.rangeStart !== void 0 || options2.rangeEnd !== void 0;
|
|
1533
|
+
const start = options2.rangeStart ?? 0;
|
|
1534
|
+
const end = options2.rangeEnd ?? Number.MAX_SAFE_INTEGER;
|
|
1535
|
+
const eventRows = windowed ? await this.store.getEventsByTimeRange(start, end) : await this.store.scanAll();
|
|
1536
|
+
const candidates = eventRows.flatMap(projectEventToFacts).filter((row) => row.metricKey === parsed.metric);
|
|
1376
1537
|
const touchesTags = parsed.filters.some((f) => f.key === "tags") || parsed.groupBy.includes("tags");
|
|
1377
1538
|
const noteTags = await this.loadNoteTags(candidates, touchesTags);
|
|
1378
1539
|
const matched = this.applyEffortScope(
|
|
@@ -1516,29 +1677,14 @@ var QueryService = class {
|
|
|
1516
1677
|
}
|
|
1517
1678
|
return matched.some((r) => r.effortSlug === void 0) ? matched.filter((r) => r.effortSlug === void 0) : matched;
|
|
1518
1679
|
}
|
|
1519
|
-
/**
|
|
1520
|
-
*
|
|
1521
|
-
*
|
|
1680
|
+
/** Summary facts for one Canonical Metric Key across the given content ids —
|
|
1681
|
+
* the cross-store join source. Reads finalize-written summary rows straight
|
|
1682
|
+
* off the content index (ticket 003: the store is authoritative; the old
|
|
1683
|
+
* freshness re-derivation is moot). One fact row per result × rowKey. */
|
|
1522
1684
|
async deriveMetricFacts(contentIds, metricKey) {
|
|
1523
|
-
const out = [];
|
|
1524
1685
|
const ids = [...new Set(contentIds)];
|
|
1525
|
-
await Promise.all(ids.map(
|
|
1526
|
-
|
|
1527
|
-
for (const result of results) {
|
|
1528
|
-
const facts = normalizeSummaryFacts(result.data.logs ?? [], {
|
|
1529
|
-
noteId: result.noteId,
|
|
1530
|
-
resultId: result.id,
|
|
1531
|
-
segmentId: result.segmentId,
|
|
1532
|
-
segmentVersion: result.segmentVersion,
|
|
1533
|
-
blockContentId,
|
|
1534
|
-
origin: result.origin,
|
|
1535
|
-
pageId: result.pageId,
|
|
1536
|
-
workoutTimestamp: result.createdAt
|
|
1537
|
-
});
|
|
1538
|
-
for (const f of facts) if (f.metricKey === metricKey) out.push(f);
|
|
1539
|
-
}
|
|
1540
|
-
}));
|
|
1541
|
-
return out;
|
|
1686
|
+
const rows = await Promise.all(ids.map((blockContentId) => this.store.getEventsByContent(blockContentId)));
|
|
1687
|
+
return rows.flat().filter((row) => row.grain === "summary").flatMap(projectEventToFacts).filter((f) => f.metricKey === metricKey);
|
|
1542
1688
|
}
|
|
1543
1689
|
/** All content blocks across the journal + static corpus. */
|
|
1544
1690
|
async allContentBlocks() {
|
|
@@ -1578,7 +1724,7 @@ var QueryService = class {
|
|
|
1578
1724
|
const noteTags = /* @__PURE__ */ new Map();
|
|
1579
1725
|
if (!touchesTags) return noteTags;
|
|
1580
1726
|
const noteIds = [...new Set(rows.map((r) => r.noteId))];
|
|
1581
|
-
await Promise.all(noteIds.map(async (id) => noteTags.set(id, await this.
|
|
1727
|
+
await Promise.all(noteIds.map(async (id) => noteTags.set(id, await this.noteStore.getNoteTagLabels(id))));
|
|
1582
1728
|
return noteTags;
|
|
1583
1729
|
}
|
|
1584
1730
|
};
|
|
@@ -1878,15 +2024,15 @@ sum:$metric{} rollup:1w
|
|
|
1878
2024
|
}
|
|
1879
2025
|
|
|
1880
2026
|
// src/version.ts
|
|
1881
|
-
var VERSION = "0.6.
|
|
1882
|
-
var GIT_SHA = "
|
|
1883
|
-
var BUILD_TIME = "2026-08-
|
|
2027
|
+
var VERSION = "0.6.36";
|
|
2028
|
+
var GIT_SHA = "c5ad2b0";
|
|
2029
|
+
var BUILD_TIME = "2026-08-24T20:14:33.951Z";
|
|
1884
2030
|
var SEMVER = {
|
|
1885
|
-
version: "0.6.
|
|
1886
|
-
gitSha: "
|
|
1887
|
-
buildTime: "2026-08-
|
|
2031
|
+
version: "0.6.36",
|
|
2032
|
+
gitSha: "c5ad2b0",
|
|
2033
|
+
buildTime: "2026-08-24T20:14:33.951Z"
|
|
1888
2034
|
};
|
|
1889
2035
|
|
|
1890
|
-
export { BUILD_TIME, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, EFFORT_DISCIPLINES, GIT_SHA, KG_PER_LB, PLANNED_WIDGET_TYPES, QueryService, SEMVER, UNIT_FAMILIES, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms_exports as wqlTerms };
|
|
2036
|
+
export { BUILD_TIME, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, EFFORT_DISCIPLINES, GIT_SHA, KG_PER_LB, PLANNED_WIDGET_TYPES, QueryService, SEMVER, UNIT_FAMILIES, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms_exports as wqlTerms };
|
|
1891
2037
|
//# sourceMappingURL=index.mjs.map
|
|
1892
2038
|
//# sourceMappingURL=index.mjs.map
|