refactor: centralize display timezone config#264
Conversation
Centralizes the user-facing timezone in app.display_timezone (env DISPLAY_TIMEZONE) so modules no longer hardcode 'America/Sao_Paulo'.
Replace hardcoded 'America/Sao_Paulo' with config('app.display_timezone')
and use parameterized SQL bindings for AT TIME ZONE clauses.
Add AT TIME ZONE conversion to activity heatmap SQL query and convert SLA deadline display to use the configured display timezone.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR centralizes a configurable display timezone (config('app.display_timezone')) and replaces hard-coded or server-local time usage across the codebase: config, analytics queries (day/hour bucketing), Blade components and Livewire views (timestamp conversion/status), console command logging, scheduled task timezone, and a migration converting messages.sent_at to timestamptz. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@app-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/VoiceHeatmap.php`:
- Around line 23-24: The VoiceHeatmap query uses selectRaw on occurred_at to
extract dow/hour but only applies a single AT TIME ZONE conversion, causing
incorrect buckets for naive UTC timestamps; update the two selectRaw calls in
VoiceHeatmap.php that reference EXTRACT(DOW FROM occurred_at ...) and
EXTRACT(HOUR FROM occurred_at ...) to first interpret the timestamp as UTC then
convert to the target timezone by changing the expression to use AT TIME ZONE
'UTC' AT TIME ZONE ? and keep passing the $tz parameter for both calls.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro
Run ID: d9538447-540c-4ec5-a68e-89a2e869ebb2
📒 Files selected for processing (16)
app-modules/bot-discord/src/Events/GreetingsEvent.phpapp-modules/he4rt/resources/views/components/dashboard/heatmap.blade.phpapp-modules/he4rt/resources/views/components/schedule-card.blade.phpapp-modules/integration-discord/src/ETL/Console/BackfillVoiceLogsCommand.phpapp-modules/panel-admin/resources/views/moderation/appeal-queue/appeal-detail.blade.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/ActivityPerDay.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/MessageHeatmap.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/PeriodStats.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/TopChannels.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/VoiceHeatmap.phpapp-modules/panel-admin/src/Marketing/Pages/Discord/Dashboard/Queries/VoicePerDay.phpapp-modules/panel-admin/src/Marketing/Pages/MeetingShowcasePage.phpapp-modules/panel-admin/src/Moderation/Livewire/ModerationDashboardLivewire.phpconfig/app.phpresources/views/livewire/connection-hub.blade.phproutes/console.php
…nversion VoiceHeatmap and VoicePerDay used single AT TIME ZONE which tells PostgreSQL the naive timestamp IS in that timezone. The correct pattern is double conversion (AT TIME ZONE 'UTC' AT TIME ZONE ?) to first interpret as UTC then convert to the display timezone.
Converts the naive timestamp column to timestamptz, interpreting existing values as UTC. Matches the voice_messages.occurred_at migration from 2026-05-19.
Now that sent_at and created_at are timestamptz columns, PostgreSQL already knows they are UTC. Double AT TIME ZONE conversion is only needed for naive timestamp columns.
Converts the naive timestamp column to timestamptz, interpreting existing values as UTC to match the Discord API source data.
All timestamp columns (sent_at, occurred_at, created_at) are now timestamptz — PostgreSQL already knows they are UTC. Double conversion is only needed for naive timestamp columns.
Align Docker Compose env vars and Dockerfile to use Etc/UTC instead of America/Sao_Paulo so the database stores and returns timestamps in UTC.
The double conversion (AT TIME ZONE 'UTC' AT TIME ZONE ?) was inverting the timezone offset, causing dates to shift forward. A single AT TIME ZONE ? is correct for timestamptz columns.
https://github.com/user-attachments/assets/4175d3ec-095e-4ee9-80de-3e57c4a967ee <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Description This pull request introduces a new navbar component for the portal module with an animated underline hover effect. The navbar displays navigation links (Comunidade, Sobre, Projetos, Depoimentos, Contato) and a Discord button. The links feature a smooth CSS animation that expands an underline bar on hover and focus states, using Tailwind CSS utilities and CSS custom properties. ## References Related recent changes: - PR `#264`: Centralize display timezone config ## Dependencies & Requirements No new dependencies or configuration changes required. The feature uses only existing Tailwind CSS utilities and CSS pseudo-elements. ## Contributor Summary | Contributor | Lines Added | Lines Removed | Files Changed | |---|---|---|---| | andrefelipe18 | 43 | 0 | 1 | ## Changes Summary | File Path | Change Description | |---|---| | app-modules/portal/resources/views/components/navbar.blade.php | New navbar component with navigation links and animated underline hover effect using `after:` pseudo-elements with transition animations tied to `--primary` CSS variable | <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/he4rt/heartdevs.com/pull/265?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
app.display_timezoneconfig key (DISPLAY_TIMEZONEenv, defaultAmerica/Sao_Paulo) to centralize the user-facing timezoneapp.timezonedefault fromAmerica/Sao_PaulotoUTC'America/Sao_Paulo'occurrences across 15 files withconfig('app.display_timezone')?) forAT TIME ZONEclauses instead of string interpolationAT TIME ZONEconversion to moderation heatmap SQL that was missing it entirelyModules affected
config/app.php— new config keybot-discord— GreetingsEventhe4rt— heatmap highlight + schedule-cardpanel-admin— marketing dashboard queries (6 files) + moderation heatmap + appeal viewsintegration-discord— BackfillVoiceLogsCommand CLI outputroutes/console.php— backup:monitor scheduleresources/views— connection-hubTest plan
AT TIME ZONE ?binding works via tinkerDescription
Centralizes the user-facing timezone by adding app.display_timezone (env DISPLAY_TIMEZONE, default America/Sao_Paulo) and switching the application default timezone to UTC. Replaces hard-coded America/Sao_Paulo occurrences with config('app.display_timezone'), parameterizes SQL AT TIME ZONE bindings, fixes a missing AT TIME ZONE in the moderation heatmap, and converts user-facing timestamp displays to the new display timezone.
References
Dependencies & Requirements
Contributor Summary
Changes Summary