Conversation
4fbe958 to
dff4445
Compare
dff4445 to
5f4e06d
Compare
5f4e06d to
980a15e
Compare
706f061 to
a29ccdf
Compare
0c293c7 to
e521791
Compare
0ac0a8f to
034c8ee
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical and moderate review findings remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 3
Open (4)
What changed in this PR
Introduces a database-backed background-job system and moves file line recounting to asynchronous processing.
Changes:
- Adds job persistence, handlers, runners, locking, recovery, and scheduling.
- Exposes read/delete job APIs with OpenAPI support.
- Updates recount flows, models, tests, and CI configuration.
| File | Description |
|---|---|
src/migrations/postgres/20260917160500_background-jobs.sql |
PostgreSQL job schema |
src/migrations/mysql/20260917160500_background-jobs.sql |
MySQL job schema |
src/inc/utils/UserUtils.php |
Detaches jobs from deleted users |
src/inc/utils/LockUtils.php |
Nonblocking lock acquisition |
src/inc/utils/Lock.php |
Background-job lock support |
src/inc/utils/FileUtils.php |
Validated file line counts |
src/inc/utils/BackgroundJobUtils.php |
Job enqueue and deletion helpers |
src/inc/jobs/handlers/RecountFileJob.php |
File recount handler |
src/inc/jobs/BackgroundJobRunner.php |
Claims, executes, and recovers jobs |
src/inc/jobs/BackgroundJobResult.php |
Job result representation |
src/inc/jobs/BackgroundJobRegistry.php |
Handler registry |
src/inc/jobs/BackgroundJobHandler.php |
Handler contract |
src/inc/handlers/FileHandler.php |
Enqueues UI recount requests |
src/inc/defines/DBackgroundJobType.php |
Job type definitions |
src/inc/defines/DBackgroundJobStatus.php |
Job status definitions |
src/inc/cron.php |
Runner entrypoint |
src/inc/apiv2/openapi/SpecSanitizer.php |
OpenAPI value handling |
src/inc/apiv2/openapi/RouteIntrospector.php |
Reflection imports |
src/inc/apiv2/openapi/FeatureTypeMapper.php |
JSON field mapping |
src/inc/apiv2/model/BackgroundJobAPI.php |
Background-job API |
src/inc/apiv2/helper/RecountFileLinesHelperAPI.php |
Asynchronous recount flow |
src/inc/apiv2/common/ApiRegistry.php |
API registration |
src/inc/apiv2/common/AbstractBaseAPI.php |
JSON conversion and permissions |
src/dba/models/generator.php |
Job model metadata |
src/dba/models/BackgroundJobFactory.php |
Job factory |
src/dba/models/BackgroundJob.php |
Job model |
src/dba/Factory.php |
Factory registration |
src/dba/AbstractModelFactory.php |
JSON SQL handling and update results |
openapi.json |
Generated API specification |
docker-entrypoint.sh |
Scheduler loop |
ci/phpunit/inc/utils/BackgroundJobUtilsTest.php |
Runner unit tests |
ci/phpunit/dba/UpdateSetTest.php |
Update result assertions |
ci/phpunit/dba/AbstractModelFactoryTest.php |
Mass-update assertions |
ci/apiv2/utils.py |
Background-job test model |
ci/apiv2/test_permissions.py |
Permission-flow coverage |
ci/apiv2/test_file.py |
Recount API test updates |
ci/apiv2/test_backgroundjob.py |
Background-job API tests |
.github/docker-compose.postgres.yml |
Disables scheduler in PostgreSQL CI |
.github/docker-compose.mysql.yml |
Disables scheduler in MySQL CI |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| $factory = Factory::getBackgroundJobFactory(); | ||
| while (true) { | ||
| $job = $factory->filter([ | ||
| Factory::FILTER => new QueryFilter(BackgroundJob::STATUS, DBackgroundJobStatus::PENDING, "="), |
There was a problem hiding this comment.
Code looks great, but it would it be nice to also have support for reoccuring jobs. ex. cleaning the speed database every 10 minutes. It would be nice that instead of checking on pending, we can have a field with a time that the job is scheduled for, this can then work for both non occuring as occuring jobs, occuring jobs can then update this time after completing their job
be357bb to
58fd6fa
Compare
…ieved and replacec claim() function raw sql with DBA functions
… to avoid test issues locally
3e75a63 to
0ee56d5
Compare


Introduces a generic, database-backed background job system for long-running server operations. Jobs store their type, JSON payload, triggering user, lifecycle timestamps, status, exit code, and result message. A locked runner processes pending jobs sequentially, prevents overlapping executions, records failures, and recovers stale jobs. The container entrypoint invokes the runner every 60 seconds, with an environment variable to disable the scheduler.
File line recounting is migrated to the new asynchronous flow, so UI and API requests enqueue work instead of blocking. A read/delete-only API exposes job status and results; running jobs cannot be deleted.