Conversation
|
@iamdharmesh I based this branch on your branch feature/200 |
There was a problem hiding this comment.
Pull request overview
Adds a new “Forms performance over time” chart to the Mailchimp → Analytics admin page, backed by a new admin-only AJAX endpoint that aggregates local analytics DB rows into chart-ready series.
Changes:
- Registers a new
wp_ajax_mailchimp_sf_get_form_performanceendpoint and data provider for per-form submissions-over-time aggregation. - Adds a new Analytics card (markup + JS module) rendering a Chart.js line chart with loading/empty/error states.
- Adds SCSS styling for the new Form Performance analytics section.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
mailchimp.php |
Bootstraps the new Form Performance data provider on plugin init. |
includes/class-mailchimp-form-performance.php |
Implements the AJAX handler, DB query, and bucketing/aggregation logic for the chart payload. |
includes/admin/templates/analytics.php |
Adds the new “Forms performance over time” card markup, error banner, and canvas placeholder. |
assets/js/analytics.js |
Introduces a new frontend module that fetches/render form performance data and manages UI states. |
assets/css/analytics.scss |
Styles the new Form Performance section to match existing analytics card patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Build the complete ordered set of bucket keys covering the range. | ||
| $buckets = array(); | ||
| $one_day = new DateInterval( 'P1D' ); | ||
| $cursor = $from_dt; | ||
| while ( $cursor <= $to_dt ) { | ||
| $date = $cursor->format( 'Y-m-d' ); | ||
| $key = $this->get_bucket_key( $date, $interval, $tz ); | ||
| if ( ! isset( $buckets[ $key ] ) ) { | ||
| $buckets[ $key ] = array( | ||
| 'key' => $key, | ||
| 'label' => $this->get_bucket_label( $date, $interval, $tz ), | ||
| 'views' => 0, | ||
| 'submissions' => 0, | ||
| ); | ||
| } | ||
| $cursor = $cursor->add( $one_day ); | ||
| } |
There was a problem hiding this comment.
aggregate() builds buckets by iterating over every day in the requested range, even when the chosen interval is monthly/quarterly/yearly. For large custom ranges this is O(days) work and can be slow in admin-ajax. Consider iterating by bucket interval boundaries instead (or enforcing a max range), so runtime scales with number of buckets rather than number of days.
There was a problem hiding this comment.
Iteration cost is negligible at realistic date ranges. Proper bucket-step refactor can land if it ever becomes a performance concern
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…into feature/form-performance-chart
Description of the Change
Adds the Forms performance over time chart to the Analytics admin page.
How to test the Change
Changelog Entry
Credits
Props @alaca
Checklist: