Repository navigation
fix(core): treat an empty project filter as omitted in session stats - #51644
Serenity-2026 wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Small note, only about the test — the The
So the unfixed behaviour is a collapsed period, not just a zero count. The added test pins // No explicit from, so this also exercises the derived-range path at stats.ts:101.
const allProjects = yield* SessionStats.get({ to: Date.UTC(2026, 1, 1), timezone: "UTC" })
const emptyProject = yield* SessionStats.get({
projectID: Project.ID.make(""),
to: Date.UTC(2026, 1, 1),
timezone: "UTC",
})
expect(emptyProject).toEqual(allProjects)Verified both ways: passes on this branch, fails on unfixed If it's easier than retyping, it's on |
SessionStats.get compared projectID against undefined, so projectID = "" became a literal session.project_id = '' filter and matched no rows (and skewed the derived default start time). Treat an empty project ID as omitted, matching the truthiness guard used for Project.ID in permission/saved.ts. Closes anomalyco#51534
33ea750 to
8998cac
Compare
|
Thanks, good catch. I updated the test to omit |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #51534
Type of change
What does this PR do?
SessionStats.getcomparedprojectIDagainstundefined, soprojectID: ""became a literalsession.project_id = ''filter and matched no rows, and the same filter skewed the derived default start time. An empty project ID is now treated as omitted, matching the truthiness guard used forProject.IDinpackages/core/src/permission/saved.ts.How did you verify your code works?
Added an assertion in
packages/core/test/session-stats.test.tsthat an empty project ID returns the same result as no filter. It does not pinfrom, so it also covers the derived-range query that shares the same filter; it fails on unpatchedv2and passes here. Frompackages/core:bun test test/session-stats.test.tsandbun run typecheck.Screenshots / recordings
N/A — core logic.
Checklist
If you do not follow this template your PR will be automatically rejected.