fix: respect session prefetch page size (#1332)
Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
81c72df8ea
commit
65e288bb71
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { shouldSkipSessionPrefetch } from "../session-prefetch-cache"
|
||||
|
||||
describe("shouldSkipSessionPrefetch", () => {
|
||||
test("does not skip a larger fetch when only a smaller partial prefetch is cached", () => {
|
||||
expect(shouldSkipSessionPrefetch({
|
||||
hasMessages: true,
|
||||
info: { limit: 50, complete: false, at: 1_000 },
|
||||
pageSize: 200,
|
||||
now: 1_001,
|
||||
})).toBe(false)
|
||||
})
|
||||
|
||||
test("still skips a recent partial prefetch when cached coverage matches the request", () => {
|
||||
expect(shouldSkipSessionPrefetch({
|
||||
hasMessages: true,
|
||||
info: { limit: 200, complete: false, at: 1_000 },
|
||||
pageSize: 200,
|
||||
now: 1_001,
|
||||
})).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -35,6 +35,7 @@ export function shouldSkipSessionPrefetch(input: {
|
||||
if (!input.info) return true
|
||||
if (input.info.complete) return true
|
||||
if (input.info.limit > input.pageSize) return true
|
||||
if (input.info.limit < input.pageSize) return false
|
||||
} else {
|
||||
if (!input.info) return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user