Skip to content

fix(users): #27993 Online Users 'All time' filter returns empty#28145

Merged
sonika-shah merged 2 commits into
mainfrom
fix/online-users-all-time-filter
May 18, 2026
Merged

fix(users): #27993 Online Users 'All time' filter returns empty#28145
sonika-shah merged 2 commits into
mainfrom
fix/online-users-all-time-filter

Conversation

@sonika-shah
Copy link
Copy Markdown
Collaborator

@sonika-shah sonika-shah commented May 15, 2026

Summary

Closes #27993.

The /v1/users/online endpoint computed the SQL threshold as now - timeWindow*60*1000. When the UI sent timeWindow=0 for the All time dropdown option, the threshold collapsed to now, producing lastActivityTime > 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 in CollectionDAO.java already handles a missing lastActivityTimeGreaterThan correctly).

Files

  • openmetadata-service/.../UserResource.java — gate the lastActivityTimeGreaterThan filter on timeWindow > 0
  • openmetadata-integration-tests/.../UserResourceIT.java — new test test_listOnlineUsers_allTimeWindow_returnsUsers that calls /v1/users/online?timeWindow=0 and asserts non-empty response, count >= a finite window, and no bots. The test fails on main and passes with the fix.

Test plan

  • mvn test -pl openmetadata-integration-tests -Dtest=UserResourceIT#test_listOnlineUsers_allTimeWindow_returnsUsers against a local server
  • Manual: in the UI, open Settings → Members → Online Users, select All time — list populates with all non-bot users

Summary by Gitar

  • Alerts:
    • Fixed thread events to correctly trigger entity-scoped notification alerts.

This will update automatically on new commits.

Copilot AI review requested due to automatic review settings May 15, 2026 12:02
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels May 15, 2026
@sonika-shah sonika-shah force-pushed the fix/online-users-all-time-filter branch from 0652ee7 to 2e43d36 Compare May 15, 2026 12:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 listOnlineUsers to only apply lastActivityTimeGreaterThan when timeWindow > 0 (so 0 becomes “all time”).
  • Add an integration test covering /v1/users/online?timeWindow=0 and 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.

Comment on lines +364 to +368
filter.addQueryParam("isBot", "false");
if (timeWindow > 0) {
long thresholdTimestamp = System.currentTimeMillis() - (timeWindow * 60 * 1000L);
filter.addQueryParam("lastActivityTimeGreaterThan", String.valueOf(thresholdTimestamp));
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings May 15, 2026 12:12
@sonika-shah sonika-shah force-pushed the fix/online-users-all-time-filter branch from 2e43d36 to 4dc960e Compare May 15, 2026 12:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

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.
@sonika-shah sonika-shah force-pushed the fix/online-users-all-time-filter branch from 4dc960e to f4a4ee9 Compare May 15, 2026 12:30
@sonika-shah sonika-shah added the To release Will cherry-pick this PR into the release branch label May 15, 2026
yan-3005
yan-3005 previously approved these changes May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

🟡 Playwright Results — all passed (12 flaky)

✅ 4135 passed · ❌ 0 failed · 🟡 12 flaky · ⏭️ 86 skipped

Shard Passed Failed Flaky Skipped
✅ Shard 1 299 0 0 4
🟡 Shard 2 775 0 6 8
🟡 Shard 3 801 0 2 7
🟡 Shard 4 751 0 1 12
🟡 Shard 5 772 0 1 47
🟡 Shard 6 737 0 2 8
🟡 12 flaky test(s) (passed on retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/ChangeSummaryBadge.spec.ts › AI badge should NOT appear for manually-edited descriptions (shard 2, 1 retry)
  • Features/DataQuality/BundleSuiteBulkOperations.spec.ts › Create new Bundle Suite with bulk selected test cases (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should display correct status badge color and icon (shard 2, 2 retries)
  • Features/KnowledgeCenter.spec.ts › Article mentions in description should working for Knowledge Center (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Advanced Blocks (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 3, 1 retry)
  • Pages/DescriptionVisibility.spec.ts › Glossary Term truncates long description and end of text is not visible before expand (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Column dropdown drag-and-drop functionality for Glossary Terms table (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)

📦 Download artifacts

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
Copilot AI review requested due to automatic review settings May 17, 2026 17:08
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 17, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Updates 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

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/UserResource.java:334-336
The @Parameter description for timeWindow lists examples for positive values (1, 5, 60, 1440) but doesn't mention that 0 (or any non-positive value) means "all time / unbounded". Since this is the intended behavior for the UI's "All time" option, documenting it in the OpenAPI description helps API consumers and prevents confusion.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonika-shah sonika-shah enabled auto-merge (squash) May 17, 2026 17:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines 369 to +373

// 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) {
Comment on lines +2164 to +2169
@Test
void test_listOnlineUsers_allTimeWindow_includesUserWithNoActivity(TestNamespace ns) {
String name = ns.prefix("onlineAllTime");
CreateUser createRequest =
new CreateUser()
.withName(name)
@sonarqubecloud
Copy link
Copy Markdown

@sonika-shah sonika-shah merged commit 2ca2677 into main May 18, 2026
64 of 66 checks passed
@sonika-shah sonika-shah deleted the fix/online-users-all-time-filter branch May 18, 2026 05:02
@github-actions
Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 1.13 branch.
Please cherry-pick the changes manually.
You can find more details here.

@github-actions
Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 1.12.9 branch.
Please cherry-pick the changes manually.
You can find more details here.

sonika-shah added a commit that referenced this pull request May 18, 2026
…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.
sonika-shah added a commit that referenced this pull request May 18, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Online Users page not working with All filter

3 participants