MCPcopy Index your code
hub / github.com/simstudioai/sim / selectRowsByIdChunks

Function selectRowsByIdChunks

apps/sim/lib/cleanup/batch-delete.ts:43–61  ·  view source on GitHub ↗
(
  ids: string[],
  query: (chunkIds: string[], chunkLimit: number) => Promise<T[]>,
  {
    overallLimit = DEFAULT_BATCH_SIZE * DEFAULT_MAX_BATCHES_PER_TABLE,
    chunkSize = DEFAULT_WORKSPACE_CHUNK_SIZE,
  }: SelectByIdChunksOptions = {}
)

Source from the content-addressed store, hash-verified

41 * timeout.
42 */
43export async function selectRowsByIdChunks<T>(
44 ids: string[],
45 query: (chunkIds: string[], chunkLimit: number) => Promise<T[]>,
46 {
47 overallLimit = DEFAULT_BATCH_SIZE * DEFAULT_MAX_BATCHES_PER_TABLE,
48 chunkSize = DEFAULT_WORKSPACE_CHUNK_SIZE,
49 }: SelectByIdChunksOptions = {}
50): Promise<T[]> {
51 if (ids.length === 0) return []
52
53 const rows: T[] = []
54 for (const chunkIds of chunkArray(ids, chunkSize)) {
55 if (rows.length >= overallLimit) break
56 const remaining = overallLimit - rows.length
57 const chunkRows = await query(chunkIds, remaining)
58 rows.push(...chunkRows)
59 }
60 return rows
61}
62
63export interface TableCleanupResult {
64 table: string

Callers 4

cleanupRunChildrenFunction · 0.90
runCleanupTasksFunction · 0.90
runCleanupSoftDeletesFunction · 0.90

Calls 2

chunkArrayFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected