@bitcobblers/wod-wiki-engine 0.63.2271 → 0.63.2272

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/agent.cjs CHANGED
@@ -1988,12 +1988,33 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
1988
1988
  const rawEventStore = {
1989
1989
  getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
1990
1990
  getEventsByMetricDates: async (dates) => {
1991
+ if (dates.length === 0) return [];
1991
1992
  const store = storage.readonly("events");
1992
1993
  const byId = /* @__PURE__ */ new Map();
1993
- for (const date of dates) {
1994
- for (const row of await store.getAllFromIndex("by-metric-date", date)) {
1994
+ if (dates.length === 1) {
1995
+ for (const row of await store.getAllFromIndex("by-metric-date", dates[0])) {
1995
1996
  byId.set(row.id, row);
1996
1997
  }
1998
+ return Array.from(byId.values());
1999
+ }
2000
+ let minDate = dates[0];
2001
+ let maxDate = dates[0];
2002
+ const wanted = /* @__PURE__ */ new Set();
2003
+ for (const date of dates) {
2004
+ wanted.add(date);
2005
+ if (date < minDate) minDate = date;
2006
+ if (date > maxDate) maxDate = date;
2007
+ }
2008
+ const rows = await store.getAllFromIndex(
2009
+ "by-metric-date",
2010
+ asRange(minDate, maxDate)
2011
+ );
2012
+ for (const row of rows) {
2013
+ if (byId.has(row.id)) continue;
2014
+ if (Array.isArray(row.metricDateKeys) && row.metricDateKeys.length > 0) {
2015
+ if (!row.metricDateKeys.some((k) => wanted.has(k))) continue;
2016
+ }
2017
+ byId.set(row.id, row);
1997
2018
  }
1998
2019
  return Array.from(byId.values());
1999
2020
  },
@@ -4400,7 +4421,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
4400
4421
  }
4401
4422
 
4402
4423
  // src/version.ts
4403
- var VERSION = "0.63.2271";
4424
+ var VERSION = "0.63.2272";
4404
4425
 
4405
4426
  // src/feed/qr.ts
4406
4427
  var APP_ORIGIN = "https://wod.wiki";