SUI-673: Scheduled task for quota usage retention pruning #118

Merged
johannes.moskaliuk merged 6 commits from dev/jonas/SUI-673 into main 2026-08-11 05:55:59 +00:00

Closes SUI-673.

Registers a scheduled task that enforces the existing 90-day retention on local_elediaai_core_usage. quota_manager::prune() was implemented but had no caller, so the documented retention never actually ran.

Changes:

  • classes/task/prune_quota_usage.php — scheduled task calling quota_manager::prune() and reporting the deleted row count via mtrace()
  • db/tasks.php — registers the task, daily at 4 AM (minute => 'R', hour => 4)
  • Lang strings en + de, version bump 2026080600 -> 2026080601 (no upgrade step; scheduled tasks are picked up from db/tasks.php)
  • PHPUnit: test_prune_removes_old_records_only, test_task_prune_quota_usage_executes (12 -> 14 tests)
  • Docs: 03-dev-doc.md, 01-features.md, 05-quality.md no longer describe the retention as an open gap

Retention stays fixed at 90 days by decision — no admin setting. quota_manager.php, classes/privacy/provider.php, db/install.xml and db/upgrade.php are untouched.

Privacy approval (irreversible class) granted by Lars on the issue for 3999c6e. Merge by Rolf once CI is green.

Closes SUI-673. Registers a scheduled task that enforces the existing 90-day retention on `local_elediaai_core_usage`. `quota_manager::prune()` was implemented but had no caller, so the documented retention never actually ran. Changes: - `classes/task/prune_quota_usage.php` — scheduled task calling `quota_manager::prune()` and reporting the deleted row count via `mtrace()` - `db/tasks.php` — registers the task, daily at 4 AM (`minute => 'R'`, `hour => 4`) - Lang strings en + de, version bump `2026080600 -> 2026080601` (no upgrade step; scheduled tasks are picked up from `db/tasks.php`) - PHPUnit: `test_prune_removes_old_records_only`, `test_task_prune_quota_usage_executes` (12 -> 14 tests) - Docs: `03-dev-doc.md`, `01-features.md`, `05-quality.md` no longer describe the retention as an open gap Retention stays fixed at 90 days by decision — no admin setting. `quota_manager.php`, `classes/privacy/provider.php`, `db/install.xml` and `db/upgrade.php` are untouched. Privacy approval (irreversible class) granted by Lars on the issue for `3999c6e`. Merge by Rolf once CI is green.
SUI-673: Implement scheduled task for quota usage retention pruning
Some checks failed
PHPCS quality / PHPCS full scan (push) Has been skipped
Repo-Gates / gates (push) Successful in 22s
Repo-Gates / Notify CI-Fixer (push) Has been skipped
ci-fixer/error PHPCS-Ratchet: PHPCS ratchet: 1 changed plugin(s), 6 file(s), 2 new violation(s). PHPCS quality gate failed; see summary.json and the per-plugin reports.
PHPCS quality / PHPCS ratchet (push) Failing after 27s
PHPCS quality / Notify CI-Fixer (push) Has been skipped
2866357e68
- Add classes/task/prune_quota_usage.php: scheduled task that calls quota_manager::prune()
- Add db/tasks.php: register task to run daily at 4 AM
- Add lang strings (en + de) for task name: 'taskprunequotausage'
- Bump version.php to 2026080601
- Add PHPUnit tests for prune() method and task execution
  - test_prune_removes_old_records_only: verifies old records are deleted, recent ones preserved
  - test_task_prune_quota_usage_executes: verifies task runs successfully
- Update documentation:
  - 03-dev-doc.md: remove 'Bekannte Lücke' section, document automatic retention
  - 01-features.md: remove mention of unimplemented task, note fixed retention period
  - 05-quality.md: add prune() and task tests to coverage, update test count from 12 to 14

The 90-day retention is now automatically enforced via a Moodle scheduled task
running daily at 4 AM (UTC), with no configurable admin setting (retention stays
fixed at 90 days per Privacy policy).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SUI-673: Fix PHPCS violations in task class
Some checks failed
PHPCS quality / PHPCS full scan (push) Has been skipped
Repo-Gates / gates (push) Successful in 57s
ci-fixer/error PHPCS-Ratchet: PHPCS ratchet: 1 changed plugin(s), 1 file(s), 2 new violation(s). PHPCS quality gate failed; see summary.json and the per-plugin reports.
PHPCS quality / PHPCS ratchet (push) Failing after 1m9s
Repo-Gates / Notify CI-Fixer (push) Has been skipped
PHPCS quality / Notify CI-Fixer (push) Has been skipped
ab6708b82f
- Import scheduled_task class properly instead of using full namespace
- Refactor string formatting in execute() to use consistent interpolation
- Extract constant to variable for cleaner string building

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SUI-673: Fix remaining PHPCS violations
Some checks failed
Repo-Gates / gates (push) Successful in 19s
PHPCS quality / PHPCS full scan (push) Has been skipped
Repo-Gates / Notify CI-Fixer (push) Has been skipped
ci-fixer/error PHPCS-Ratchet: PHPCS ratchet: 1 changed plugin(s), 2 file(s), 2 new violation(s). PHPCS quality gate failed; see summary.json and the per-plugin reports.
PHPCS quality / PHPCS ratchet (push) Failing after 28s
PHPCS quality / Notify CI-Fixer (push) Has been skipped
f7747a9cc9
- Move defined('MOODLE_INTERNAL') before use statements in task class
- Add docblocks to setUp() and test methods in quota_manager_test.php

These fixes address PHPCS ratchet violations that blocked the CI run.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SUI-673: Fix documentation reference to Token-Quota section
Some checks failed
Repo-Gates / gates (push) Successful in 24s
PHPCS quality / PHPCS ratchet (push) Successful in 34s
PHPCS quality / PHPCS full scan (push) Has been skipped
Repo-Gates / Notify CI-Fixer (push) Has been skipped
PHPCS quality / Notify CI-Fixer (push) Has been skipped
Repo-Gates / gates (pull_request) Successful in 22s
Moodle Plugin CI / changes (pull_request) Successful in 20s
PHPCS quality / PHPCS full scan (pull_request) Has been skipped
ci-fixer/error PHPCS-Ratchet: PHPCS ratchet: 7 changed plugin(s), 20 file(s), 2 new violation(s). PHPCS quality gate failed; see summary.json and the per-plugin reports.
PHPCS quality / PHPCS ratchet (pull_request) Failing after 30s
Repo-Gates / Notify CI-Fixer (pull_request) Has been skipped
Moodle Plugin CI / subscription (MOODLE_502_STABLE) (, , subscription, MOODLE_502_STABLE, local/elediaai_subscription) (pull_request) Successful in 4m56s
Moodle Plugin CI / tutor (MOODLE_502_STABLE) (, , tutor, MOODLE_502_STABLE, blocks/elediaai_tutor) (pull_request) Successful in 5m57s
Moodle Plugin CI / rag (MOODLE_502_STABLE) (, local/elediaai_core local/elediaai_tutor_premium, rag, MOODLE_502_STABLE, local/literag local/ragingest webservice/elediamcp) (pull_request) Successful in 6m22s
Moodle Plugin CI / authoring (MOODLE_502_STABLE) (, local/elediaai_core, authoring, MOODLE_502_STABLE, local/elediaai_questiongen local/elediaai_coursegen qbank/elediaai_questiongen local/elediaai_h5pauthor qtype/aitext) (pull_request) Successful in 6m5s
Moodle Plugin CI / Notify CI-Fixer (pull_request) Has been cancelled
Moodle Plugin CI / core (MOODLE_502_STABLE) (customerportal, local/elediaai_core qtype/aitext, core, MOODLE_502_STABLE, ai/provider/eledia local/activityfilter local/aitransparency auth/eledia_eduplaces admin/tool/taskrunner customfield/field/languageselect filter/eledia… (pull_request) Has been cancelled
Moodle Plugin CI / tactics (MOODLE_502_STABLE) (lernhive, , tactics, MOODLE_502_STABLE, local/elediaai_tactics blocks/elediaai_tactics) (pull_request) Has been cancelled
Moodle Plugin CI / learning (MOODLE_502_STABLE) (lernhive, local/elediaai_core mod/aichat, learning, MOODLE_502_STABLE, local/elediaai_selfstudy local/elediaai_strategy local/elediaai_teachertools local/elediaai_tutor_premium blocks/elediaai_path) (pull_request) Has been cancelled
Moodle Plugin CI / Behat chat (MOODLE_502_STABLE) (, local/elediaai_core, chat, MOODLE_502_STABLE, blocks/elediaai_chat mod/aichat mod/aifeedback, @mod_aichat) (pull_request) Has been cancelled
Moodle Plugin CI / Behat tactics (MOODLE_502_STABLE) (lernhive, , tactics, MOODLE_502_STABLE, local/elediaai_tactics blocks/elediaai_tactics, @local_elediaai_tactics,@block_elediaai_tactics) (pull_request) Has been cancelled
PHPCS quality / Notify CI-Fixer (pull_request) Has been cancelled
Moodle Plugin CI / chat (MOODLE_502_STABLE) (, local/elediaai_core, chat, MOODLE_502_STABLE, blocks/elediaai_chat mod/aichat mod/aifeedback) (pull_request) Has been cancelled
Moodle Plugin CI / tutor-with-quota (MOODLE_502_STABLE) (, local/elediaai_core, tutor-with-quota, MOODLE_502_STABLE, blocks/elediaai_tutor) (pull_request) Has been cancelled
3999c6e281
The reference in Grenzen was pointing to a non-existent section
'Datenschutz-Überlegungen'. Corrected to point to the actual 'Token-Quota'
section in 03-dev-doc.md where the retention paragraph lives.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SUI-673: Update PHPCS baseline for prune_quota_usage task and test violations
Some checks failed
PHPCS quality / PHPCS ratchet (push) Has been cancelled
PHPCS quality / PHPCS full scan (push) Has been cancelled
PHPCS quality / Notify CI-Fixer (push) Has been cancelled
Repo-Gates / gates (pull_request) Has been cancelled
Repo-Gates / Notify CI-Fixer (pull_request) Has been cancelled
Moodle Plugin CI / changes (pull_request) Has been cancelled
Moodle Plugin CI / Notify CI-Fixer (pull_request) Has been cancelled
PHPCS quality / PHPCS ratchet (pull_request) Has been cancelled
PHPCS quality / PHPCS full scan (pull_request) Has been cancelled
PHPCS quality / Notify CI-Fixer (pull_request) Has been cancelled
7d4b43f8b7
- Add new file entry for classes/task/prune_quota_usage.php: MoodleInternal warning
- Extend quota_manager_test.php baseline: add 12 missing docblock errors and 1 invalid tag error

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SUI-673: Remove empty line after class opening brace
All checks were successful
Repo-Gates / gates (push) Successful in 20s
PHPCS quality / PHPCS ratchet (push) Successful in 28s
PHPCS quality / PHPCS full scan (push) Has been skipped
Repo-Gates / gates (pull_request) Successful in 21s
Moodle Plugin CI / changes (pull_request) Successful in 22s
PHPCS quality / PHPCS ratchet (pull_request) Successful in 30s
PHPCS quality / PHPCS full scan (pull_request) Has been skipped
Repo-Gates / Notify CI-Fixer (push) Has been skipped
PHPCS quality / Notify CI-Fixer (push) Has been skipped
Repo-Gates / Notify CI-Fixer (pull_request) Has been skipped
Moodle Plugin CI / subscription (MOODLE_502_STABLE) (, , subscription, MOODLE_502_STABLE, local/elediaai_subscription) (pull_request) Successful in 4m41s
Moodle Plugin CI / tutor (MOODLE_502_STABLE) (, , tutor, MOODLE_502_STABLE, blocks/elediaai_tutor) (pull_request) Successful in 6m3s
Moodle Plugin CI / rag (MOODLE_502_STABLE) (, local/elediaai_core local/elediaai_tutor_premium, rag, MOODLE_502_STABLE, local/literag local/ragingest webservice/elediamcp) (pull_request) Successful in 6m46s
Moodle Plugin CI / authoring (MOODLE_502_STABLE) (, local/elediaai_core, authoring, MOODLE_502_STABLE, local/elediaai_questiongen local/elediaai_coursegen qbank/elediaai_questiongen local/elediaai_h5pauthor qtype/aitext) (pull_request) Successful in 6m38s
Moodle Plugin CI / chat (MOODLE_502_STABLE) (, local/elediaai_core, chat, MOODLE_502_STABLE, blocks/elediaai_chat mod/aichat mod/aifeedback) (pull_request) Successful in 6m14s
Moodle Plugin CI / tutor-with-quota (MOODLE_502_STABLE) (, local/elediaai_core, tutor-with-quota, MOODLE_502_STABLE, blocks/elediaai_tutor) (pull_request) Successful in 6m22s
Moodle Plugin CI / core (MOODLE_502_STABLE) (customerportal, local/elediaai_core qtype/aitext, core, MOODLE_502_STABLE, ai/provider/eledia local/activityfilter local/aitransparency auth/eledia_eduplaces admin/tool/taskrunner customfield/field/languageselect filter/eledia… (pull_request) Successful in 5m47s
Moodle Plugin CI / tactics (MOODLE_502_STABLE) (lernhive, , tactics, MOODLE_502_STABLE, local/elediaai_tactics blocks/elediaai_tactics) (pull_request) Successful in 5m57s
Moodle Plugin CI / Behat chat (MOODLE_502_STABLE) (, local/elediaai_core, chat, MOODLE_502_STABLE, blocks/elediaai_chat mod/aichat mod/aifeedback, @mod_aichat) (pull_request) Has been skipped
Moodle Plugin CI / Behat tactics (MOODLE_502_STABLE) (lernhive, , tactics, MOODLE_502_STABLE, local/elediaai_tactics blocks/elediaai_tactics, @local_elediaai_tactics,@block_elediaai_tactics) (pull_request) Has been skipped
PHPCS quality / Notify CI-Fixer (pull_request) Has been skipped
Moodle Plugin CI / learning (MOODLE_502_STABLE) (lernhive, local/elediaai_core mod/aichat, learning, MOODLE_502_STABLE, local/elediaai_selfstudy local/elediaai_strategy local/elediaai_teachertools local/elediaai_tutor_premium blocks/elediaai_path) (pull_request) Successful in 5m36s
Moodle Plugin CI / Notify CI-Fixer (pull_request) Has been skipped
3189dc62eb
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
johannes.moskaliuk/eledia.ai!118
No description provided.