Skip to content

feat: nethvoice stats nightly refresh (materialized views)#154

Open
gsanchietti wants to merge 2 commits into
masterfrom
nethvoice_stats
Open

feat: nethvoice stats nightly refresh (materialized views)#154
gsanchietti wants to merge 2 commits into
masterfrom
nethvoice_stats

Conversation

@gsanchietti

@gsanchietti gsanchietti commented Jun 30, 2026

Copy link
Copy Markdown
Member

What

Adds nightly-refreshed nethvoice_* and phonehome_* materialized views so Metabase/Grafana can query pre-flattened stats without live JSONB unpacking.

Key files

  • database/migrations/2026_06_30_120000_nethvoice_stats_materialized_views.php — creates 12 materialized views via DB::statement()
  • app/Jobs/RefreshNethvoiceStatsMaterializedViews.php — refreshes views in dependency order
  • app/Console/Kernel.php — schedules job nightly at 02:00 with withoutOverlapping()
  • app/Console/Commands/NethvoiceRefreshStatsCommand.phpphp artisan nethvoice:refresh-stats for manual runs

PhoneHome dashboard views

Same pattern applied to the PhoneHome Grafana dashboard:

  • phonehome_installations, phonehome_nethserver8_node_versions, phonehome_daily_active_counts — replace the JSONB-unpacking queries in phonehome.json with plain SELECTs.
  • Nightly refresh: RefreshPhonehomeDashboardMaterializedViews job, phonehome:refresh-dashboard-stats command, scheduled dailyAt('02:15').
  • Dashboard panels rewired to the new views (containers/grafana/provisioning/dashboards/phonehome.json).
  • Grants SELECT to the Grafana DB user.

@gsanchietti gsanchietti changed the title feat: nethvoice stats nightly refresh feat: nethvoice stats nightly refresh (materialized views) Jun 30, 2026
@gsanchietti gsanchietti marked this pull request as ready for review July 1, 2026 10:59
@gsanchietti gsanchietti requested a review from Tbaile July 1, 2026 10:59

@Tbaile Tbaile left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let me help supporting podman-compose, what version are you running?

Comment thread README.md Outdated
Add materialized view for NethVoice statistics.
This change greatly increase query performances
on BI tools.

Assisted-By: Claude:Sonnet4.6
@gsanchietti gsanchietti marked this pull request as draft July 1, 2026 12:41
@gsanchietti

Copy link
Copy Markdown
Member Author

Let me help supporting podman-compose, what version are you running?

Not need at all

PR back to draft because I'm going to introduce optimizations for the main grafana dashboard

Pre-compute the PhoneHome Grafana dashboard's JSONB-heavy queries into
materialized views (phonehome_installations,
phonehome_nethserver8_node_versions, phonehome_daily_active_counts)
refreshed nightly, and rewire the dashboard panels to read from them
instead of scanning installations/countries live on every load.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gsanchietti gsanchietti marked this pull request as ready for review July 1, 2026 14:21
@gsanchietti gsanchietti requested a review from Tbaile July 1, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants