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

Method readFilteredPage

src/db/queries.ts:2024–2044  ·  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

2022 * reading of a negative limit (no limit) this follows.
2023 */
2024 private readFilteredPage<T extends { name: string; file_path: string }>(
2025 sql: string,
2026 params: (string | number)[],
2027 filters: FieldFilters,
2028 limit: number,
2029 offset: number,
2030 ): T[] {
2031 const page: T[] = [];
2032 if (limit === 0) return page;
2033 let skipped = 0;
2034 for (const row of this.db.prepare(sql).iterate(...params) as IterableIterator<T>) {
2035 if (!passesFieldFilters(row.name, row.file_path, filters)) continue;
2036 if (skipped < offset) {
2037 skipped++;
2038 continue;
2039 }
2040 page.push(row);
2041 if (page.length === limit) break;
2042 }
2043 return page;
2044 }
2045
2046 /**
2047 * 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