MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readFilteredPage

Method readFilteredPage

src/db/queries.ts:2040–2060  ·  view source on GitHub ↗

* One page of the rows `sql` returns that pass `filters`: up to `limit` of * them, after skipping the first `offset` that pass, so a source's limit and * offset count only what the filters let through. `sql` has no LIMIT or * OFFSET of its own. Its rows are streamed and the read stops once

(
    sql: string,
    params: (string | number)[],
    filters: FieldFilters,
    limit: number,
    offset: number,
  )

Source from the content-addressed store, hash-verified

2038 * reading of a negative limit (no limit) this follows.
2039 */
2040 private readFilteredPage<T extends { name: string; file_path: string }>(
2041 sql: string,
2042 params: (string | number)[],
2043 filters: FieldFilters,
2044 limit: number,
2045 offset: number,
2046 ): T[] {
2047 const page: T[] = [];
2048 if (limit === 0) return page;
2049 let skipped = 0;
2050 for (const row of this.db.prepare(sql).iterate(...params) as IterableIterator<T>) {
2051 if (!passesFieldFilters(row.name, row.file_path, filters)) continue;
2052 if (skipped < offset) {
2053 skipped++;
2054 continue;
2055 }
2056 page.push(row);
2057 if (page.length === limit) break;
2058 }
2059 return page;
2060 }
2061
2062 /**
2063 * Match-everything path used when the user supplied only field

Callers 5

searchNodesMethod · 0.95
searchAllByFiltersMethod · 0.95
searchNodesFuzzyMethod · 0.95
searchNodesFTSMethod · 0.95
searchNodesLikeMethod · 0.95

Calls 4

passesFieldFiltersFunction · 0.85
pushMethod · 0.80
iterateMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected