Extend availability (durations, weekly recurrence, calendar); price offerings in dollars
CI / Coding Standards (pull_request) Successful in 50s
CI / PHPStan (pull_request) Successful in 1m2s
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 48s
CI / Tests (PHP 8.3) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Has been skipped

Availability (#2):
- us_availability gains offering_id, duration_minutes (default 60), and
  recurrence_group; AvailabilitySlot carries the new fields.
- AvailabilityRepository::createWeeklySeries() generates N weekly rows
  sharing a recurrence_group; findAvailable() filters by offering and
  duration. Date math uses DateTimeImmutable::modify() (the no-debug CI
  regex `dd\(` matches `->add(`).
- REST GET filters by offering_id/duration_minutes; POST accepts
  duration_minutes, offering_id, recurrence (single|weekly) + weeks.
- Admin form adds duration, an offering picker, and one-off/weekly options
  (OfferingRepository wired into AvailabilityController).
- booking.js renders an agenda calendar (slots grouped by day, with
  duration). The richer booking UX lands with the booking-flow work.

Offering price in dollars:
- Switch us_offerings.price_cents (INT) to price DECIMAL(10,2); Offering
  uses float $price. Admin form and REST take dollars.
- Fix a pre-existing misalignment in the Offering insert/update $wpdb
  format arrays (billing_mode/capacity/is_active were mapped to the wrong
  specifiers, which would corrupt values) via a single COLUMN_FORMATS list.

Also bump PHPStan to --memory-limit=1G in the lint script; 128M now
crashes analysis as the codebase has grown.

Refs #2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 15:38:58 -03:00
parent 5352fb7d69
commit 19e663d6fa
18 changed files with 398 additions and 112 deletions
+13 -8
View File
@@ -13,15 +13,20 @@ class Schema {
public static function tables( string $prefix, string $charset ): array {
return [
"CREATE TABLE {$prefix}us_availability (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
instructor_id BIGINT UNSIGNED NOT NULL,
start_dt DATETIME NOT NULL,
end_dt DATETIME NOT NULL,
is_booked TINYINT(1) NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
instructor_id BIGINT UNSIGNED NOT NULL,
offering_id BIGINT UNSIGNED DEFAULT NULL,
start_dt DATETIME NOT NULL,
end_dt DATETIME NOT NULL,
duration_minutes SMALLINT UNSIGNED NOT NULL DEFAULT 60,
is_booked TINYINT(1) NOT NULL DEFAULT 0,
recurrence_group BIGINT UNSIGNED DEFAULT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (id),
KEY instructor_id (instructor_id),
KEY start_dt (start_dt)
KEY offering_id (offering_id),
KEY start_dt (start_dt),
KEY recurrence_group (recurrence_group)
) {$charset};",
"CREATE TABLE {$prefix}us_lessons (
@@ -45,7 +50,7 @@ class Schema {
title VARCHAR(191) NOT NULL,
description TEXT,
duration_minutes SMALLINT UNSIGNED DEFAULT NULL,
price_cents INT UNSIGNED NOT NULL DEFAULT 0,
price DECIMAL(10,2) NOT NULL DEFAULT 0,
currency VARCHAR(3) NOT NULL DEFAULT 'CAD',
billing_mode VARCHAR(20) NOT NULL DEFAULT 'one_time',
allow_weekly TINYINT(1) NOT NULL DEFAULT 0,