UN-3320 [FIX] Show days in TTL time display instead of only hours#1847
UN-3320 [FIX] Show days in TTL time display instead of only hours#1847chandrasekharan-zipstack merged 8 commits intomainfrom
Conversation
The formatTimeDisplay helper was computing hours from total seconds without extracting days first, resulting in large hour values like "2011h 45m" instead of "83d 19h 45m". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Cache: Disabled due to Reviews > Disable Cache setting Knowledge base: Disabled due to Summary by CodeRabbit
WalkthroughAdds day-level granularity to frontend time formatting and introduces a backend utility to batch-resolve string user IDs to user name/email mappings. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
Generic utility to batch resolve stringified user PKs to display names and emails in a single query. Used by HITL manual review for resolving reviewer/approver IDs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/utils/user_utils.py (1)
30-35: Consider usingget_full_name()for more user-friendly display names.The current approach derives the display name from the email prefix (
user.email.split("@")[0]). However, theUsermodel extends Django'sAbstractUser, which providesfirst_nameandlast_namefields and aget_full_name()method specifically for this purpose. Seed data in the repository already populates these fields when creating users.Using
get_full_name()would produce more readable names (e.g., "John Doe" instead of "john.doe.123") when available.♻️ Proposed refactor to use get_full_name()
lookup = {} for user in User.objects.filter(pk__in=pk_set): - display_name = user.email.split("@")[0] if user.email else user.username + display_name = ( + user.get_full_name() + or (user.email.split("@")[0] if user.email else None) + or user.username + ) info = {"name": display_name, "email": user.email} lookup[str(user.pk)] = info🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/utils/user_utils.py` around lines 30 - 35, Replace the current display name logic inside the loop that builds lookup (the for user in User.objects.filter(...) block) to prefer Django's user.get_full_name() when available; specifically, set display_name = user.get_full_name() if that returns a non-empty string, otherwise fall back to user.email.split("@")[0] if user.email exists, and finally to user.username — update only the assignment of display_name so lookup[str(user.pk)] = info remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@backend/utils/user_utils.py`:
- Around line 30-35: Replace the current display name logic inside the loop that
builds lookup (the for user in User.objects.filter(...) block) to prefer
Django's user.get_full_name() when available; specifically, set display_name =
user.get_full_name() if that returns a non-empty string, otherwise fall back to
user.email.split("@")[0] if user.email exists, and finally to user.username —
update only the assignment of display_name so lookup[str(user.pk)] = info
remains unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5123f356-5bd7-4c6c-8f30-e60a28968b6b
📒 Files selected for processing (1)
backend/utils/user_utils.py
Greptile SummaryThis PR delivers two independent improvements: a display-only fix for the HITL TTL countdown (adds a days tier to Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["formatTimeDisplay(seconds)"] --> B{seconds <= 0?}
B -- Yes --> C["return 'Expired'"]
B -- No --> D["days = floor(seconds / 86400)"]
D --> E["hours = floor((seconds % 86400) / 3600)"]
E --> F["minutes = floor((seconds % 3600) / 60)"]
F --> G["secs = floor(seconds % 60)"]
G --> H{days > 0?}
H -- Yes --> I["parts.push(days + 'd')"]
H -- No --> J{hours > 0?}
I --> J
J -- Yes --> K["parts.push(hours + 'h')"]
J -- No --> L{minutes > 0?}
K --> L
L -- Yes --> M["parts.push(minutes + 'm')"]
L -- No --> N{secs > 0 or parts empty?}
M --> N
N -- Yes --> O["parts.push(secs + 's')"]
N -- No --> P["return parts.join(' ')"]
O --> P
Q["batch_resolve_user_ids(user_ids)"] --> R["Iterate user_ids or []"]
R --> S["Try int(uid) → add to pk_set"]
S --> T{pk_set empty?}
T -- Yes --> U["return {}"]
T -- No --> V["User.objects.filter(pk__in=pk_set)"]
V --> W["Build display_name:\nget_full_name()\nor email prefix\nor username"]
W --> X["lookup[str(user.pk)] = {name, email}"]
X --> Y["return lookup"]
Last reviewed commit: 821cdc9 |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com>
Reverts the Iterable[str] type annotation that was added without importing Iterable, which broke the pre-commit check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add type annotations (Iterable[str] param, dict return type) - Clarify docstring that unresolved PKs are omitted - Coerce user.email None to empty string - Fix early-return guard for generator inputs - Prefer get_full_name() for display names Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/utils/user_utils.py (1)
32-37: Consider limiting fetched fields for query efficiency.Since only
pk,first_name,last_name,usernameare used, you could useonly()to avoid fetching unused columns.♻️ Proposed optimization
- for user in User.objects.filter(pk__in=pk_set): + for user in User.objects.filter(pk__in=pk_set).only( + "pk", "first_name", "last_name", "email", "username" + ):🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/utils/user_utils.py` around lines 32 - 37, Looping over User.objects.filter(pk__in=pk_set) fetches full rows; restrict columns by adding .only('pk', 'first_name', 'last_name', 'email', 'username') to the query used in this loop in backend/utils/user_utils.py so that the display name computation (user.get_full_name(), user.email, user.username) only loads those fields and avoids pulling unused columns.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@backend/utils/user_utils.py`:
- Around line 32-37: Looping over User.objects.filter(pk__in=pk_set) fetches
full rows; restrict columns by adding .only('pk', 'first_name', 'last_name',
'email', 'username') to the query used in this loop in
backend/utils/user_utils.py so that the display name computation
(user.get_full_name(), user.email, user.username) only loads those fields and
avoids pulling unused columns.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dc55e846-8b31-489b-8f62-9f1da5d8bdd3
📒 Files selected for processing (1)
backend/utils/user_utils.py
Frontend Lint Report (Biome)✅ All checks passed! No linting or formatting issues found. |
Test ResultsSummary
Runner Tests - Full Report
|
|



What
formatTimeDisplayhelper to include days in TTL time displaybatch_resolve_user_idsutility inutils/user_utils.pyfor resolving stringified user PKs to display namesWhy
manual_review_v2/views.py; extracted into a shared OSS utility for reuseHow
GetStaticData.js: Added days calculation (Math.floor(seconds / 86400)) and adjusted hours to use remainderutils/user_utils.py: New generic utility that batch resolves stringified integer PKs to{'name', 'email'}dicts via a single DB queryCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
user_utils.pyis a new file with no existing callers in OSS — it's consumed by the cloud repo.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
utils/user_utils.pyfrom this PRDependencies Versions
Notes on Testing
utils.user_utils.batch_resolve_user_ids— merge this firstScreenshots
N/A
Checklist
I have read and understood the Contribution Guidelines.