- Add implementation notes for cancellation and waitlist features. - Create task documentation outlining goals, current status, and acceptance criteria for cancellation policy and resource utilization reporting. - Establish architecture for domain events and outbox pattern to ensure reliable event publishing. - Define database schema for domain events and necessary queries for resource utilization and plan accuracy reports. - Implement detailed implementation notes covering edge cases, testing strategies, and documentation requirements.
2.7 KiB
2.7 KiB
دیتابیس — تسک ۱۰
policy_simulation_runs
تنها جدول جدید این تسک — و تنها چیزی که شبیهسازی مینویسد.
| ستون | نوع | توضیح |
|---|---|---|
id |
INT PK AI | |
uuid |
VARCHAR(36) UNIQUE | |
entity_type / entity_id |
VARCHAR(10) / INT NOT NULL | |
policy_id |
INT NOT NULL | FK → policies.id ON DELETE CASCADE |
policy_version |
SMALLINT NOT NULL | نسخهٔ آزمایششده |
sample_size |
SMALLINT NOT NULL | تعداد نوبت نمونه |
affected_count |
SMALLINT NOT NULL | تعداد تحت تأثیر |
severity |
VARCHAR(10) NOT NULL | none|low|medium|high |
report |
JSON NOT NULL | ردیفهای تفصیلی (حداکثر ۵۰) |
run_by |
INT NULL | FK → users.id ON DELETE SET NULL |
created_at |
INT NOT NULL |
KEY idx_psr_policy (policy_id, policy_version, created_at)
KEY idx_psr_tenant (entity_type, entity_id, created_at)
report سقف حجم دارد: ۵۰ ردیف × چند فیلد ≈ چند کیلوبایت. بیشتر ذخیره نکن — گزارش
تفصیلیتر با اجرای دوباره به دست میآید.
هیچ تغییری در جدولهای دیگر
policies.active از قبل هست. شرط آزمایش در سطح سرویس اعمال میشود، نه schema.
نمونهگیری — SimulationSampler
-- نوبتهای واقعی، مرتبط با دامنهٔ قانون، جدیدترین اول
SELECT a.* FROM appointments a
WHERE a.entity_type = :type AND a.entity_id = :id
AND a.status IN ('confirmed','completed')
AND (:branchId IS NULL OR a.branch_id = :branchId)
AND (:serviceId IS NULL OR a.service_item_id = :serviceId)
ORDER BY a.slot_start DESC
LIMIT 50
فیلتر service_item_id از خودِ شرط قانون استخراج میشود (اگر قانون سرویس مشخصی را
هدف گرفته). بدون آن، شبیهسازی قانون لیزر روی ۵۰ نوبت دندانپزشکی اجرا میشود و
«۰٪ تحت تأثیر» میدهد — که گمراهکننده است.
Migration
ddev exec php bin/console doctrine:migrations:diff --no-interaction
ddev exec php bin/console doctrine:migrations:migrate --no-interaction
پاکسازی
اجراهای آزمایشی قدیمی ارزشی ندارند:
ddev exec php bin/console app:policy:prune-simulations --older-than=30d --force
آخرین اجرا per (policy, version) هرگز حذف نمیشود — چون شرط activate به آن وابسته است.
طبقهبندی tenant
| جدول | وضعیت |
|---|---|
policy_simulation_runs |
جفت tenant |