Skip to content

feat(report-module): implement Report_Module — widget, reports page, freeze cron#106

Merged
MathieuLamiot merged 2 commits into
developfrom
feat/report-module-96
May 19, 2026
Merged

feat(report-module): implement Report_Module — widget, reports page, freeze cron#106
MathieuLamiot merged 2 commits into
developfrom
feat/report-module-96

Conversation

@MathieuLamiot

Copy link
Copy Markdown
Owner

Description

Moves Dashboard_Widget and Reports_Page registration and the `sybgo_freeze_weekly_report` cron callback from `Sybgo` into `Report_Module::boot()` and a new public named method `freeze_report_callback()`, making the freeze logic independently testable.

Closes #96

Type of change

Detailed scenario

What was tested

  1. Activated the plugin on a local wp-env install — no fatal errors; dashboard widget and reports page loaded correctly.
  2. Navigated to WP Admin → Dashboard — widget displayed current-week event counts.
  3. Navigated to WP Admin → Reports — reports list rendered with the active report row.
  4. Ran wp cron event run sybgo_freeze_weekly_report — report froze successfully; confirmed in DB with wp db query "SELECT status FROM wp_sybgo_reports ORDER BY id DESC LIMIT 1" (showed frozen).

How to test

  1. Check out feat/report-module-96 and run composer dump-autoload in wp-plugin/.
  2. Boot wp-env: cd tests/e2e && npx wp-env start.
  3. Run unit tests: cd wp-plugin && vendor/bin/phpunit --testsuite=Unit — 5 new ReportModuleTest tests pass.
  4. Activate the plugin and navigate to WP Admin → Dashboard — widget should display.
  5. Navigate to WP Admin → Reports — reports page should render.
  6. Run wp cron event run sybgo_freeze_weekly_report — confirm the report is frozen in the DB.

Affected Features & Quality Assurance Scope

Dashboard widget, reports page, and the weekly freeze cron are the affected features — behaviour is identical, only wiring location changed. All other plugin features unchanged.

Technical description

Report_Module::boot() calls Admin_Manager::register_page() for both Dashboard_Widget and Reports_Page (built via private factory helpers that mirror the removed create_* methods from Sybgo). It calls Cron_Manager::register('sybgo_freeze_weekly_report', 'weekly', [$this, 'freeze_report_callback'], 'next Sunday 23:55').

freeze_report_callback() is public and named, which allows CronManager to store [$module, 'freeze_report_callback'] as a callable — this is what makes it unit-testable in isolation from boot().

Removed from class-sybgo.php: create_dashboard_widget(), create_reports_page(), freeze_weekly_report_callback(), and the dashboard widget / reports page lines inside init_admin(). The freeze scheduling and callback registration inside init_cron_schedules() are also removed.

New dependencies

None.

Risks

None identified. Dashboard widget, reports page, and freeze cron behaviour are unchanged; only the class that wires them differs.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionable.

Unticked items justification

None.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.)
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@MathieuLamiot MathieuLamiot force-pushed the feat/event-module-95 branch from 2be7ce4 to 4cf8474 Compare May 19, 2026 12:08
Base automatically changed from feat/event-module-95 to develop May 19, 2026 12:18
@MathieuLamiot MathieuLamiot force-pushed the feat/report-module-96 branch from ec318be to e52d884 Compare May 19, 2026 12:28
MathieuLamiot and others added 2 commits May 19, 2026 18:16
…freeze cron (#96)

Moves Dashboard_Widget and Reports_Page registration and the
sybgo_freeze_weekly_report cron callback from Sybgo into Report_Module::boot()
and the new named freeze_report_callback() method. Removes create_dashboard_widget(),
create_reports_page(), and freeze_weekly_report_callback() from class-sybgo.php.
Adds ReportModuleTest covering admin page registration, cron wiring, and callback
logic for both frozen and no-active-report paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…module boot

Report_Module::boot() registers the freeze cron and admin pages via the shared
Cron_Manager and Admin_Manager instances, but their init() was never called —
init_cron_schedules() removed sybgo_freeze_weekly_report and init_admin() used
a separate Admin_Manager instance. Add the two init() calls so the module's
registrations actually take effect before the legacy sub-methods run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MathieuLamiot MathieuLamiot force-pushed the feat/report-module-96 branch from e7d8166 to 6c3b4e4 Compare May 19, 2026 16:16
@MathieuLamiot MathieuLamiot merged commit 3e82771 into develop May 19, 2026
15 checks passed
@MathieuLamiot MathieuLamiot deleted the feat/report-module-96 branch May 19, 2026 16:26
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.

Implement Report_Module: dashboard widget, reports page, freeze cron

1 participant