Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
phphr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
phphr
Commits
af73d3c0
Commit
af73d3c0
authored
Apr 08, 2026
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 7 files via Son of Anton
parent
050451a0
Pipeline
#22
failed with stage
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
50 deletions
+38
-50
JobInterface.php
engine/Scheduler/JobInterface.php
+1
-2
JobRunner.php
engine/Scheduler/JobRunner.php
+27
-4
SessionCleanupJob.php
modules/Auth/Jobs/SessionCleanupJob.php
+1
-6
AutoArchiveDoneCardsJob.php
modules/Cards/Jobs/AutoArchiveDoneCardsJob.php
+4
-9
SendDeadlineRemindersJob.php
modules/Cards/Jobs/SendDeadlineRemindersJob.php
+3
-10
InviteExpiryJob.php
modules/Onboarding/Jobs/InviteExpiryJob.php
+1
-6
DetectUnreportedDaysJob.php
modules/Reports/Jobs/DetectUnreportedDaysJob.php
+1
-13
No files found.
engine/Scheduler/JobInterface.php
View file @
af73d3c0
...
...
@@ -5,6 +5,5 @@ namespace Engine\Scheduler;
interface
JobInterface
{
public
function
execute
()
:
void
;
public
function
nextRunAt
()
:
string
;
public
function
run
()
:
void
;
}
\ No newline at end of file
engine/Scheduler/JobRunner.php
View file @
af73d3c0
...
...
@@ -31,16 +31,30 @@ final class JobRunner
$key
=
$jobRecord
[
'job_key'
];
if
(
!
isset
(
$this
->
jobs
[
$key
]))
continue
;
// Lock check
if
(
$jobRecord
[
'last_status'
]
===
'running'
)
continue
;
$this
->
db
->
update
(
'background_jobs'
,
[
'last_status'
=>
'running'
],
'id = ?'
,
[
$jobRecord
[
'id'
]]);
try
{
$this
->
jobs
[
$key
]
->
execute
();
$job
=
$this
->
jobs
[
$key
];
// Check shouldRun() if method exists
if
(
method_exists
(
$job
,
'shouldRun'
)
&&
!
$job
->
shouldRun
())
{
$this
->
db
->
update
(
'background_jobs'
,
[
'last_run_at'
=>
date
(
'Y-m-d H:i:s'
),
'next_run_at'
=>
$this
->
jobs
[
$key
]
->
nextRunAt
(),
'next_run_at'
=>
$this
->
getNextRunAt
(
$job
),
'last_status'
=>
'success'
,
'last_error'
=>
null
,
],
'id = ?'
,
[
$jobRecord
[
'id'
]]);
$results
[
$key
]
=
'skipped (shouldRun=false)'
;
continue
;
}
$job
->
run
();
$this
->
db
->
update
(
'background_jobs'
,
[
'last_run_at'
=>
date
(
'Y-m-d H:i:s'
),
'next_run_at'
=>
$this
->
getNextRunAt
(
$job
),
'last_status'
=>
'success'
,
'last_error'
=>
null
,
],
'id = ?'
,
[
$jobRecord
[
'id'
]]);
...
...
@@ -48,7 +62,7 @@ final class JobRunner
}
catch
(
\Throwable
$e
)
{
$this
->
db
->
update
(
'background_jobs'
,
[
'last_run_at'
=>
date
(
'Y-m-d H:i:s'
),
'next_run_at'
=>
$this
->
jobs
[
$key
]
->
nextRunAt
(
),
'next_run_at'
=>
$this
->
getNextRunAt
(
$this
->
jobs
[
$key
]
),
'last_status'
=>
'failed'
,
'last_error'
=>
$e
->
getMessage
(),
],
'id = ?'
,
[
$jobRecord
[
'id'
]]);
...
...
@@ -59,6 +73,15 @@ final class JobRunner
return
$results
;
}
private
function
getNextRunAt
(
JobInterface
$job
)
:
string
{
if
(
method_exists
(
$job
,
'nextRunAt'
))
{
return
$job
->
nextRunAt
();
}
// Default: run again in 1 hour
return
date
(
'Y-m-d H:i:s'
,
strtotime
(
'+1 hour'
));
}
public
function
initializeJob
(
string
$key
)
:
void
{
$exists
=
$this
->
db
->
fetchOne
(
"SELECT id FROM background_jobs WHERE job_key = ?"
,
[
$key
]);
...
...
modules/Auth/Jobs/SessionCleanupJob.php
View file @
af73d3c0
...
...
@@ -16,13 +16,8 @@ final class SessionCleanupJob implements JobInterface
$this
->
sessions
=
Container
::
getInstance
()
->
resolve
(
SessionManager
::
class
);
}
public
function
execute
()
:
void
public
function
run
()
:
void
{
$this
->
sessions
->
cleanup
();
}
public
function
nextRunAt
()
:
string
{
return
date
(
'Y-m-d H:i:s'
,
strtotime
(
'+1 day'
));
}
}
\ No newline at end of file
modules/Cards/Jobs/AutoArchiveDoneCardsJob.php
View file @
af73d3c0
...
...
@@ -16,7 +16,7 @@ final class AutoArchiveDoneCardsJob implements JobInterface
$this
->
db
=
Container
::
getInstance
()
->
resolve
(
Connection
::
class
);
}
public
function
execute
()
:
void
public
function
run
()
:
void
{
$boards
=
$this
->
db
->
fetchAll
(
"SELECT id, auto_archive_done_days FROM boards WHERE is_archived = 0"
);
...
...
@@ -33,9 +33,4 @@ final class AutoArchiveDoneCardsJob implements JobInterface
);
}
}
public
function
nextRunAt
()
:
string
{
return
date
(
'Y-m-d 03:00:00'
,
strtotime
(
'+1 day'
));
}
}
\ No newline at end of file
modules/Cards/Jobs/SendDeadlineRemindersJob.php
View file @
af73d3c0
...
...
@@ -20,9 +20,8 @@ final class SendDeadlineRemindersJob implements JobInterface
$this
->
notif
=
$c
->
resolve
(
NotificationManager
::
class
);
}
public
function
execute
()
:
void
public
function
run
()
:
void
{
// Cards due in 2 days
$twoDays
=
date
(
'Y-m-d'
,
strtotime
(
'+2 days'
));
$cards
=
$this
->
db
->
fetchAll
(
"SELECT c.id, c.card_key, c.title, c.deadline FROM cards c
...
...
@@ -42,7 +41,6 @@ final class SendDeadlineRemindersJob implements JobInterface
}
}
// Cards due today
$today
=
date
(
'Y-m-d'
);
$todayCards
=
$this
->
db
->
fetchAll
(
"SELECT c.id, c.card_key, c.title FROM cards c
...
...
@@ -62,9 +60,4 @@ final class SendDeadlineRemindersJob implements JobInterface
}
}
}
public
function
nextRunAt
()
:
string
{
return
date
(
'Y-m-d 08:00:00'
,
strtotime
(
'+1 day'
));
}
}
\ No newline at end of file
modules/Onboarding/Jobs/InviteExpiryJob.php
View file @
af73d3c0
...
...
@@ -16,15 +16,10 @@ final class InviteExpiryJob implements JobInterface
$this
->
db
=
Container
::
getInstance
()
->
resolve
(
Connection
::
class
);
}
public
function
execute
()
:
void
public
function
run
()
:
void
{
$this
->
db
->
query
(
"UPDATE invites SET status = 'expired' WHERE status = 'active' AND expires_at < NOW()"
);
}
public
function
nextRunAt
()
:
string
{
return
date
(
'Y-m-d 00:05:00'
,
strtotime
(
'+1 day'
));
}
}
\ No newline at end of file
modules/Reports/Jobs/DetectUnreportedDaysJob.php
View file @
af73d3c0
...
...
@@ -20,12 +20,11 @@ final class DetectUnreportedDaysJob implements JobInterface
$this
->
notif
=
$c
->
resolve
(
NotificationManager
::
class
);
}
public
function
execute
()
:
void
public
function
run
()
:
void
{
$yesterday
=
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
));
$dayOfWeek
=
(
int
)
date
(
'w'
,
strtotime
(
$yesterday
));
// Get all active contractors
$contractors
=
$this
->
db
->
fetchAll
(
"SELECT u.id, u.full_name_en FROM users u WHERE u.role = 'contractor' AND u.status = 'active'"
);
...
...
@@ -33,42 +32,36 @@ final class DetectUnreportedDaysJob implements JobInterface
foreach
(
$contractors
as
$contractor
)
{
$userId
=
$contractor
[
'id'
];
// Check if yesterday was a working day
$isWorkDay
=
$this
->
db
->
fetchOne
(
"SELECT 1 FROM user_schedule_days WHERE user_id = ? AND day_of_week = ? AND work_mode != 'off' AND effective_to IS NULL"
,
[
$userId
,
$dayOfWeek
]
);
if
(
!
$isWorkDay
)
continue
;
// Check holiday
$isHoliday
=
$this
->
db
->
fetchOne
(
"SELECT 1 FROM holidays WHERE start_date <= ? AND end_date >= ?"
,
[
$yesterday
,
$yesterday
]
);
if
(
$isHoliday
)
continue
;
// Check unavailability
$isUnavailable
=
$this
->
db
->
fetchOne
(
"SELECT 1 FROM unavailability_records WHERE user_id = ? AND start_date <= ? AND end_date >= ?"
,
[
$userId
,
$yesterday
,
$yesterday
]
);
if
(
$isUnavailable
)
continue
;
// Check if report exists
$hasReport
=
$this
->
db
->
fetchOne
(
"SELECT 1 FROM daily_reports WHERE user_id = ? AND report_date = ?"
,
[
$userId
,
$yesterday
]
);
if
(
$hasReport
)
continue
;
// Create unreported record
$this
->
db
->
insert
(
'daily_reports'
,
[
'user_id'
=>
$userId
,
'report_date'
=>
$yesterday
,
'status'
=>
'unreported'
,
]);
// Notify contractor
$this
->
notif
->
createImportant
(
$userId
,
'Unreported Day'
,
...
...
@@ -76,9 +69,4 @@ final class DetectUnreportedDaysJob implements JobInterface
);
}
}
public
function
nextRunAt
()
:
string
{
return
date
(
'Y-m-d 01:00:00'
,
strtotime
(
'+1 day'
));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment