fix(users): #27993 Online Users 'All time' filter returns empty#28145
Conversation
0652ee7 to
2e43d36
Compare
There was a problem hiding this comment.
Pull request overview
Fixes the /v1/users/online endpoint behavior when the UI requests All time (timeWindow=0) by avoiding a threshold that collapses to now and yields no matches, ensuring the endpoint returns all non-bot users for the unbounded case.
Changes:
- Update
listOnlineUsersto only applylastActivityTimeGreaterThanwhentimeWindow > 0(so0becomes “all time”). - Add an integration test covering
/v1/users/online?timeWindow=0and basic response expectations (non-empty and excludes bots).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java | Skips the lastActivityTimeGreaterThan filter when timeWindow <= 0 while still excluding bot users. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/UserResourceIT.java | Adds an IT to validate that timeWindow=0 returns users and excludes bots. |
| filter.addQueryParam("isBot", "false"); | ||
| if (timeWindow > 0) { | ||
| long thresholdTimestamp = System.currentTimeMillis() - (timeWindow * 60 * 1000L); | ||
| filter.addQueryParam("lastActivityTimeGreaterThan", String.valueOf(thresholdTimestamp)); | ||
| } |
There was a problem hiding this comment.
Updated: added @Min(0) so negative timeWindow is rejected with 400, and expanded the parameter description to explicitly document 0 = all time. See commit f4a4ee9.
2e43d36 to
4dc960e
Compare
The /v1/users/online endpoint computed `now - timeWindow*60*1000` for the SQL threshold. When the UI sent `timeWindow=0` for the "All time" option, the threshold collapsed to `now`, producing `lastActivityTime > now` — which matched zero rows. Skip the time predicate entirely when `timeWindow <= 0` so the filter falls through to "all non-bot users". Reported via #27993.
4dc960e to
f4a4ee9
Compare
🟡 Playwright Results — all passed (12 flaky)✅ 4135 passed · ❌ 0 failed · 🟡 12 flaky · ⏭️ 86 skipped
🟡 12 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…time-filter # Conflicts: # openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/UserResourceIT.java
Code Review ✅ Approved 1 resolved / 1 findingsUpdates the online users endpoint to skip time filtering when timeWindow is 0, resolving the empty result issue for the 'All time' filter. Added documentation for timeWindow semantics and comprehensive test coverage. ✅ 1 resolved✅ Quality: API description doesn't document timeWindow=0 semantics
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
|
||
| // Create filter for online users - uses both lastLoginTime and lastActivityTime | ||
| ListFilter filter = new ListFilter(Include.NON_DELETED); | ||
| filter.addQueryParam("lastActivityTimeGreaterThan", String.valueOf(thresholdTimestamp)); | ||
| filter.addQueryParam("isBot", "false"); // Exclude bots from online users | ||
| if (timeWindow > 0) { |
| @Test | ||
| void test_listOnlineUsers_allTimeWindow_includesUserWithNoActivity(TestNamespace ns) { | ||
| String name = ns.prefix("onlineAllTime"); | ||
| CreateUser createRequest = | ||
| new CreateUser() | ||
| .withName(name) |
|
|
Failed to cherry-pick changes to the 1.13 branch. |
|
Failed to cherry-pick changes to the 1.12.9 branch. |
…28145) (#28209) The /v1/users/online endpoint computed `now - timeWindow*60*1000` for the SQL threshold. When the UI sent `timeWindow=0` for the "All time" option, the threshold collapsed to `now`, producing `lastActivityTime > now` — which matched zero rows. Skip the time predicate entirely when `timeWindow <= 0` so the filter falls through to "all non-bot users". Reported via #27993.
…28145) (#28210) The /v1/users/online endpoint computed `now - timeWindow*60*1000` for the SQL threshold. When the UI sent `timeWindow=0` for the "All time" option, the threshold collapsed to `now`, producing `lastActivityTime > now` — which matched zero rows. Skip the time predicate entirely when `timeWindow <= 0` so the filter falls through to "all non-bot users". Reported via #27993.



Summary
Closes #27993.
The
/v1/users/onlineendpoint computed the SQL threshold asnow - timeWindow*60*1000. When the UI senttimeWindow=0for the All time dropdown option, the threshold collapsed tonow, producinglastActivityTime > now— which matches zero rows. The page therefore rendered empty whenever a user selected All.The fix skips the time predicate entirely when
timeWindow <= 0, so the filter falls through to "all non-bot users" (the existing DAO branch inCollectionDAO.javaalready handles a missinglastActivityTimeGreaterThancorrectly).Files
openmetadata-service/.../UserResource.java— gate thelastActivityTimeGreaterThanfilter ontimeWindow > 0openmetadata-integration-tests/.../UserResourceIT.java— new testtest_listOnlineUsers_allTimeWindow_returnsUsersthat calls/v1/users/online?timeWindow=0and asserts non-empty response, count >= a finite window, and no bots. The test fails onmainand passes with the fix.Test plan
mvn test -pl openmetadata-integration-tests -Dtest=UserResourceIT#test_listOnlineUsers_allTimeWindow_returnsUsersagainst a local serverSummary by Gitar
This will update automatically on new commits.