Fix Laravel Pint formatting
This commit is contained in:
@@ -13,13 +13,13 @@ use Throwable;
|
||||
class ViolationRuleEngineService
|
||||
{
|
||||
protected array $debugCompute = [];
|
||||
|
||||
protected ?array $attendanceReportedColumns = null;
|
||||
|
||||
public function __construct(
|
||||
protected AttendanceTracking $attendanceTrackingModel,
|
||||
protected AttendanceParentLookupService $parentLookupService
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getDebugCompute(): array
|
||||
{
|
||||
@@ -54,10 +54,10 @@ class ViolationRuleEngineService
|
||||
continue;
|
||||
}
|
||||
|
||||
$ymd = substr((string) ($r['date'] ?? ''), 0, 10);
|
||||
$ymd = substr((string) ($r['date'] ?? ''), 0, 10);
|
||||
$stat = strtolower(trim((string) ($r['status'] ?? '')));
|
||||
|
||||
if (!in_array($stat, ['absent', 'late'], true)) {
|
||||
if (! in_array($stat, ['absent', 'late'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ class ViolationRuleEngineService
|
||||
[$syStart, $syEnd] = $this->deriveSchoolYearBounds($schoolYear);
|
||||
|
||||
$weekRowsSource = null;
|
||||
if (!empty($weekRowsFallback)) {
|
||||
if (! empty($weekRowsFallback)) {
|
||||
foreach ($weekRowsFallback as $r) {
|
||||
$st = strtolower(trim((string) ($r['status'] ?? '')));
|
||||
if ($st !== '' && !in_array($st, ['absent', 'late'], true)) {
|
||||
if ($st !== '' && ! in_array($st, ['absent', 'late'], true)) {
|
||||
$weekRowsSource = $weekRowsFallback;
|
||||
break;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ class ViolationRuleEngineService
|
||||
return [];
|
||||
}
|
||||
|
||||
$weekIndex = array_flip($activeWeekKeys);
|
||||
$currentWeekIdx = count($activeWeekKeys) - 1;
|
||||
$windowStartIdx = max(0, $currentWeekIdx - 4);
|
||||
$weekIndex = array_flip($activeWeekKeys);
|
||||
$currentWeekIdx = count($activeWeekKeys) - 1;
|
||||
$windowStartIdx = max(0, $currentWeekIdx - 4);
|
||||
$requiredWeeksCount = $currentWeekIdx - $windowStartIdx + 1;
|
||||
|
||||
$keepLastWeeks = function (array $dates) use ($weekIndex, $windowStartIdx, $currentWeekIdx): array {
|
||||
@@ -105,17 +105,18 @@ class ViolationRuleEngineService
|
||||
}
|
||||
$out = array_values(array_unique($out));
|
||||
rsort($out);
|
||||
|
||||
return $out;
|
||||
};
|
||||
|
||||
$classByStudent = [];
|
||||
try {
|
||||
$studentIdsForClass = array_values(array_unique(array_map(
|
||||
static fn($s) => (int) ($s['id'] ?? 0),
|
||||
static fn ($s) => (int) ($s['id'] ?? 0),
|
||||
$students
|
||||
)));
|
||||
|
||||
if (!empty($studentIdsForClass)) {
|
||||
if (! empty($studentIdsForClass)) {
|
||||
$rows = DB::table('student_class as sc')
|
||||
->select([
|
||||
'sc.student_id',
|
||||
@@ -137,18 +138,18 @@ class ViolationRuleEngineService
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($classByStudent[$sid])) {
|
||||
if (! isset($classByStudent[$sid])) {
|
||||
$classByStudent[$sid] = [
|
||||
'class_section_id' => $row->class_section_id ?? null,
|
||||
'class_section_id' => $row->class_section_id ?? null,
|
||||
'class_section_name' => (string) ($row->class_section_name ?? ''),
|
||||
'class_id' => $row->class_id ?? null,
|
||||
'class_name' => (string) ($row->class_name ?? ''),
|
||||
'class_id' => $row->class_id ?? null,
|
||||
'class_name' => (string) ($row->class_name ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::debug('computeViolations(): class prefetch failed: ' . $e->getMessage());
|
||||
Log::debug('computeViolations(): class prefetch failed: '.$e->getMessage());
|
||||
}
|
||||
|
||||
$out = [];
|
||||
@@ -156,26 +157,26 @@ class ViolationRuleEngineService
|
||||
$lateCountLast5 = 0;
|
||||
|
||||
foreach ($students as $stu) {
|
||||
$sid = (int) ($stu['id'] ?? 0);
|
||||
$name = trim(($stu['firstname'] ?? '') . ' ' . ($stu['lastname'] ?? ''));
|
||||
$sid = (int) ($stu['id'] ?? 0);
|
||||
$name = trim(($stu['firstname'] ?? '').' '.($stu['lastname'] ?? ''));
|
||||
|
||||
$absDatesAll = array_values(array_unique($byStudent[$sid]['absent'] ?? []));
|
||||
$absDatesAll = array_values(array_unique($byStudent[$sid]['absent'] ?? []));
|
||||
$lateDatesAll = array_values(array_unique($byStudent[$sid]['late'] ?? []));
|
||||
|
||||
$absDates = $keepLastWeeks($absDatesAll);
|
||||
$absDates = $keepLastWeeks($absDatesAll);
|
||||
$lateDates = $keepLastWeeks($lateDatesAll);
|
||||
|
||||
if (empty($absDates) && empty($lateDates)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$absWeekIdx = $this->datesToWeekIndices($absDates, $weekIndex);
|
||||
$absWeekIdx = $this->datesToWeekIndices($absDates, $weekIndex);
|
||||
$lateWeekIdx = $this->datesToWeekIndices($lateDates, $weekIndex);
|
||||
$absCountLast5 += count($absDates);
|
||||
$absCountLast5 += count($absDates);
|
||||
$lateCountLast5 += count($lateDates);
|
||||
|
||||
$absenceViolation = null;
|
||||
if (!empty($absDates)) {
|
||||
if (! empty($absDates)) {
|
||||
$lastAbsDate = $absDates[0];
|
||||
|
||||
$A2row = $this->hasNConsecutiveItems($absDates, 2, 7);
|
||||
@@ -188,47 +189,47 @@ class ViolationRuleEngineService
|
||||
|
||||
if ($A4row || $A_in5w4) {
|
||||
$absenceViolation = [
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_4',
|
||||
'severity' => 4,
|
||||
'action' => 'expel_notify',
|
||||
'color' => '#ff4d4f',
|
||||
'title' => '4 Absences (in a row or within last 5 active weeks)',
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_4',
|
||||
'severity' => 4,
|
||||
'action' => 'expel_notify',
|
||||
'color' => '#ff4d4f',
|
||||
'title' => '4 Absences (in a row or within last 5 active weeks)',
|
||||
'description' => 'Notify team to inform parent about expulsion and send email.',
|
||||
'last_date' => $lastAbsDate,
|
||||
'last_date' => $lastAbsDate,
|
||||
];
|
||||
} elseif ($A3row || $A_in4w3) {
|
||||
$absenceViolation = [
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_3',
|
||||
'severity' => 3,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#fa8c16',
|
||||
'title' => '3 Absences (in a row or within last 4 active weeks)',
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_3',
|
||||
'severity' => 3,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#fa8c16',
|
||||
'title' => '3 Absences (in a row or within last 4 active weeks)',
|
||||
'description' => 'Team calls parent and sends email.',
|
||||
'last_date' => $lastAbsDate,
|
||||
'last_date' => $lastAbsDate,
|
||||
];
|
||||
} elseif ($A2row || $A_in3w2) {
|
||||
$absenceViolation = [
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_2',
|
||||
'severity' => 2,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#fadb14',
|
||||
'title' => '2 Absences (in a row or within last 3 active weeks)',
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_2',
|
||||
'severity' => 2,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#fadb14',
|
||||
'title' => '2 Absences (in a row or within last 3 active weeks)',
|
||||
'description' => 'Team calls parent and sends email.',
|
||||
'last_date' => $lastAbsDate,
|
||||
'last_date' => $lastAbsDate,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$lateViolation = null;
|
||||
if (!empty($lateDates)) {
|
||||
if (! empty($lateDates)) {
|
||||
$lastLateDate = $lateDates[0];
|
||||
|
||||
$L2row = $this->hasNConsecutiveItems($lateDates, 2, 7);
|
||||
$L3row = $this->hasNConsecutiveItems($lateDates, 3, 7);
|
||||
$L4row = $this->hasNConsecutiveItems($lateDates, 4, 7);
|
||||
$L2row = $this->hasNConsecutiveItems($lateDates, 2, 7);
|
||||
$L3row = $this->hasNConsecutiveItems($lateDates, 3, 7);
|
||||
$L4row = $this->hasNConsecutiveItems($lateDates, 4, 7);
|
||||
|
||||
$L_in3w2 = $this->hasNInWActiveWeeks($lateWeekIdx, 2, 3);
|
||||
$L_in4w3 = $this->hasNInWActiveWeeks($lateWeekIdx, 3, 4);
|
||||
@@ -238,7 +239,7 @@ class ViolationRuleEngineService
|
||||
$lateWeeksSet = array_flip($lateWeekIdx);
|
||||
$lateCoversAllWindowWeeks = true;
|
||||
for ($i = $windowStartIdx; $i <= $currentWeekIdx; $i++) {
|
||||
if (!isset($lateWeeksSet[$i])) {
|
||||
if (! isset($lateWeeksSet[$i])) {
|
||||
$lateCoversAllWindowWeeks = false;
|
||||
break;
|
||||
}
|
||||
@@ -247,41 +248,41 @@ class ViolationRuleEngineService
|
||||
|
||||
if ($L4row || $lateCoversAllWindowWeeks) {
|
||||
$lateViolation = [
|
||||
'type' => 'late',
|
||||
'code' => 'LATE_4',
|
||||
'severity' => 4,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#ff4d4f',
|
||||
'title' => '4 Lates in a row OR in each of the last 4 active weeks',
|
||||
'type' => 'late',
|
||||
'code' => 'LATE_4',
|
||||
'severity' => 4,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#ff4d4f',
|
||||
'title' => '4 Lates in a row OR in each of the last 4 active weeks',
|
||||
'description' => 'Team calls parent and sends email.',
|
||||
'last_date' => $lastLateDate,
|
||||
'last_date' => $lastLateDate,
|
||||
];
|
||||
} else {
|
||||
$twoLatesOneAbsWithin4 = $this->twoLatesOneAbsInWWeeks($lateWeekIdx, $absWeekIdx, 4);
|
||||
|
||||
if ($L3row || $L_in4w3 || $twoLatesOneAbsWithin4) {
|
||||
$lateViolation = [
|
||||
'type' => $twoLatesOneAbsWithin4 ? 'mix' : 'late',
|
||||
'code' => $twoLatesOneAbsWithin4 ? 'MIX_L2A1' : 'LATE_3',
|
||||
'severity' => 3,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#002766',
|
||||
'title' => $twoLatesOneAbsWithin4
|
||||
'type' => $twoLatesOneAbsWithin4 ? 'mix' : 'late',
|
||||
'code' => $twoLatesOneAbsWithin4 ? 'MIX_L2A1' : 'LATE_3',
|
||||
'severity' => 3,
|
||||
'action' => 'team_notify',
|
||||
'color' => '#002766',
|
||||
'title' => $twoLatesOneAbsWithin4
|
||||
? '2 Lates + 1 Absence (within last 4 active weeks)'
|
||||
: '3 Lates (in a row or within last 4 active weeks)',
|
||||
'description' => 'Team calls parent and sends email.',
|
||||
'last_date' => $lastLateDate,
|
||||
'last_date' => $lastLateDate,
|
||||
];
|
||||
} elseif ($L2row || $L_in3w2) {
|
||||
$lateViolation = [
|
||||
'type' => 'late',
|
||||
'code' => 'LATE_2',
|
||||
'severity' => 1,
|
||||
'action' => 'auto_email',
|
||||
'color' => '#bae7ff',
|
||||
'title' => '2 Lates (in a row or within last 3 active weeks)',
|
||||
'type' => 'late',
|
||||
'code' => 'LATE_2',
|
||||
'severity' => 1,
|
||||
'action' => 'auto_email',
|
||||
'color' => '#bae7ff',
|
||||
'title' => '2 Lates (in a row or within last 3 active weeks)',
|
||||
'description' => 'Send automated email to parent.',
|
||||
'last_date' => $lastLateDate,
|
||||
'last_date' => $lastLateDate,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -289,20 +290,20 @@ class ViolationRuleEngineService
|
||||
|
||||
$chosen = $this->chooseHigherSeverity($absenceViolation, $lateViolation);
|
||||
|
||||
if (!$chosen && count($absDates) === 1) {
|
||||
if (! $chosen && count($absDates) === 1) {
|
||||
$chosen = [
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_1',
|
||||
'severity' => 1,
|
||||
'action' => 'auto_email',
|
||||
'color' => '#e6f7ff',
|
||||
'title' => '1 Unreported Absence',
|
||||
'type' => 'absence',
|
||||
'code' => 'ABS_1',
|
||||
'severity' => 1,
|
||||
'action' => 'auto_email',
|
||||
'color' => '#e6f7ff',
|
||||
'title' => '1 Unreported Absence',
|
||||
'description' => 'Send automated email to parent.',
|
||||
'last_date' => $absDates[0],
|
||||
'last_date' => $absDates[0],
|
||||
];
|
||||
}
|
||||
|
||||
if (!$chosen) {
|
||||
if (! $chosen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -315,51 +316,51 @@ class ViolationRuleEngineService
|
||||
->where('school_year', $schoolYear)
|
||||
->where('date', '>=', $start)
|
||||
->where('date', '<', $end)
|
||||
->where('reason', 'like', '%' . $chosen['code'] . '%');
|
||||
->where('reason', 'like', '%'.$chosen['code'].'%');
|
||||
|
||||
if ($semester !== null) {
|
||||
$trackingQ->where('semester', $semester);
|
||||
}
|
||||
|
||||
$tracking = $trackingQ->orderByDesc('date')->first();
|
||||
$tracking = $tracking?->toArray() ?? [];
|
||||
$tracking = $trackingQ->orderByDesc('date')->first();
|
||||
$tracking = $tracking?->toArray() ?? [];
|
||||
$isNotified = (bool) ($tracking['is_notified'] ?? 0);
|
||||
$notifCnt = (int) ($tracking['notif_counter'] ?? 0);
|
||||
$notifCnt = (int) ($tracking['notif_counter'] ?? 0);
|
||||
|
||||
$cls = $classByStudent[$sid] ?? [];
|
||||
$classLabel = (string) ($cls['class_section_name'] ?? '');
|
||||
if ($classLabel === '' && !empty($cls['class_name'])) {
|
||||
if ($classLabel === '' && ! empty($cls['class_name'])) {
|
||||
$classLabel = (string) $cls['class_name'];
|
||||
}
|
||||
|
||||
$out[] = [
|
||||
'id' => $sid,
|
||||
'name' => $name,
|
||||
'class_name' => $classLabel,
|
||||
'id' => $sid,
|
||||
'name' => $name,
|
||||
'class_name' => $classLabel,
|
||||
'class_section_name' => (string) ($cls['class_section_name'] ?? ''),
|
||||
'className' => (string) ($cls['class_name'] ?? ''),
|
||||
'class_id' => $cls['class_id'] ?? null,
|
||||
'className' => (string) ($cls['class_name'] ?? ''),
|
||||
'class_id' => $cls['class_id'] ?? null,
|
||||
'class_section_id' => $cls['class_section_id'] ?? null,
|
||||
'parent_email' => $parent['email'] ?? '',
|
||||
'parent_name' => $parent['parent_name'] ?? '',
|
||||
'parent_phone' => $parent['phone'] ?? null,
|
||||
'violation' => $chosen['title'],
|
||||
'violation_code' => $chosen['code'],
|
||||
'type' => $chosen['type'],
|
||||
'severity' => $chosen['severity'],
|
||||
'action' => $chosen['action'],
|
||||
'color' => $chosen['color'],
|
||||
'last_absence' => $absDates[0] ?? null,
|
||||
'last_late' => $lateDates[0] ?? null,
|
||||
'last_date' => $chosen['last_date'],
|
||||
'is_notified' => $isNotified,
|
||||
'notif_counter' => $notifCnt,
|
||||
'absences' => $absDates,
|
||||
'lates' => $lateDates,
|
||||
'parent_email' => $parent['email'] ?? '',
|
||||
'parent_name' => $parent['parent_name'] ?? '',
|
||||
'parent_phone' => $parent['phone'] ?? null,
|
||||
'violation' => $chosen['title'],
|
||||
'violation_code' => $chosen['code'],
|
||||
'type' => $chosen['type'],
|
||||
'severity' => $chosen['severity'],
|
||||
'action' => $chosen['action'],
|
||||
'color' => $chosen['color'],
|
||||
'last_absence' => $absDates[0] ?? null,
|
||||
'last_late' => $lateDates[0] ?? null,
|
||||
'last_date' => $chosen['last_date'],
|
||||
'is_notified' => $isNotified,
|
||||
'notif_counter' => $notifCnt,
|
||||
'absences' => $absDates,
|
||||
'lates' => $lateDates,
|
||||
];
|
||||
}
|
||||
|
||||
$this->debugCompute['abs_last5'] = $absCountLast5;
|
||||
$this->debugCompute['abs_last5'] = $absCountLast5;
|
||||
$this->debugCompute['late_last5'] = $lateCountLast5;
|
||||
|
||||
return $out;
|
||||
@@ -370,8 +371,10 @@ class ViolationRuleEngineService
|
||||
if ($a && $b) {
|
||||
if ($a['severity'] === $b['severity']) {
|
||||
$prio = ['expel_notify' => 3, 'team_notify' => 2, 'auto_email' => 1];
|
||||
|
||||
return ($prio[$a['action']] ?? 0) >= ($prio[$b['action']] ?? 0) ? $a : $b;
|
||||
}
|
||||
|
||||
return $a['severity'] > $b['severity'] ? $a : $b;
|
||||
}
|
||||
|
||||
@@ -386,7 +389,7 @@ class ViolationRuleEngineService
|
||||
|
||||
$this->attendanceReportedColumns = [
|
||||
'is_reported' => Schema::hasColumn($table, 'is_reported'),
|
||||
'reported' => Schema::hasColumn($table, 'reported'),
|
||||
'reported' => Schema::hasColumn($table, 'reported'),
|
||||
];
|
||||
|
||||
return $this->attendanceReportedColumns;
|
||||
@@ -396,15 +399,15 @@ class ViolationRuleEngineService
|
||||
{
|
||||
$cols = $this->attendanceReportedColumns($table);
|
||||
|
||||
if (!empty($cols['is_reported'])) {
|
||||
if (! empty($cols['is_reported'])) {
|
||||
$qb->whereRaw("(LOWER(TRIM(COALESCE(is_reported, ''))) NOT IN ('yes','1','true','y','on'))");
|
||||
}
|
||||
if (!empty($cols['reported'])) {
|
||||
if (! empty($cols['reported'])) {
|
||||
$qb->whereRaw("(LOWER(TRIM(COALESCE(reported, ''))) NOT IN ('yes','1','true','y','on'))");
|
||||
}
|
||||
|
||||
$qb->whereRaw("(LOWER(COALESCE(reason, '')) NOT LIKE '%parent-reported%')")
|
||||
->whereRaw("(LOWER(COALESCE(reason, '')) NOT LIKE '%parent reported%')");
|
||||
->whereRaw("(LOWER(COALESCE(reason, '')) NOT LIKE '%parent reported%')");
|
||||
|
||||
if (Schema::hasTable('parent_attendance_reports')) {
|
||||
$qb->whereRaw("NOT EXISTS (
|
||||
@@ -418,14 +421,16 @@ class ViolationRuleEngineService
|
||||
|
||||
public function deriveSchoolYearBounds(string $schoolYear): array
|
||||
{
|
||||
if (!preg_match('/^(\d{4})-(\d{4})$/', $schoolYear, $m)) {
|
||||
$y = (int) date('Y');
|
||||
if (! preg_match('/^(\d{4})-(\d{4})$/', $schoolYear, $m)) {
|
||||
$y = (int) date('Y');
|
||||
$startY = (int) (date('n') >= 8 ? $y : $y - 1);
|
||||
|
||||
return [sprintf('%d-08-01', $startY), sprintf('%d-07-31', $startY + 1)];
|
||||
}
|
||||
|
||||
$startY = (int) $m[1];
|
||||
$endY = (int) $m[2];
|
||||
$endY = (int) $m[2];
|
||||
|
||||
return [sprintf('%d-08-01', $startY), sprintf('%d-07-31', $endY)];
|
||||
}
|
||||
|
||||
@@ -446,9 +451,10 @@ class ViolationRuleEngineService
|
||||
public function dayBounds(string $ymd): array
|
||||
{
|
||||
$d = substr($ymd, 0, 10);
|
||||
|
||||
return [
|
||||
$d . ' 00:00:00',
|
||||
date('Y-m-d', strtotime($d . ' +1 day')) . ' 00:00:00',
|
||||
$d.' 00:00:00',
|
||||
date('Y-m-d', strtotime($d.' +1 day')).' 00:00:00',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -461,10 +467,10 @@ class ViolationRuleEngineService
|
||||
): array {
|
||||
$weeks = [];
|
||||
|
||||
if (!empty($weekRowsFallback)) {
|
||||
if (! empty($weekRowsFallback)) {
|
||||
foreach ($weekRowsFallback as $r) {
|
||||
$d = $r['date'] ?? null;
|
||||
if (!$d) {
|
||||
if (! $d) {
|
||||
continue;
|
||||
}
|
||||
$ts = strtotime($d);
|
||||
@@ -490,10 +496,10 @@ class ViolationRuleEngineService
|
||||
$q->whereNull('reason')
|
||||
->orWhere(function ($q2) {
|
||||
$q2->where('reason', 'not like', '%break%')
|
||||
->where('reason', 'not like', '%cancel%');
|
||||
->where('reason', 'not like', '%cancel%');
|
||||
});
|
||||
})
|
||||
->when($semester !== null && $semester !== '', fn($q) => $q->where('semester', $semester))
|
||||
->when($semester !== null && $semester !== '', fn ($q) => $q->where('semester', $semester))
|
||||
->groupBy(DB::raw('DATE(date)'))
|
||||
->orderBy('ymd')
|
||||
->get();
|
||||
@@ -521,6 +527,7 @@ class ViolationRuleEngineService
|
||||
}
|
||||
$idx = array_keys($set);
|
||||
sort($idx);
|
||||
|
||||
return $idx;
|
||||
}
|
||||
|
||||
@@ -542,14 +549,16 @@ class ViolationRuleEngineService
|
||||
if (Str::startsWith($code, 'ABS_4')) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function isoWeekStartYmd(string $weekKey): string
|
||||
{
|
||||
if (preg_match('/^(\d{4})-W(\d{2})$/', $weekKey, $m)) {
|
||||
return date('Y-m-d', strtotime($m[1] . '-W' . $m[2] . '-1'));
|
||||
return date('Y-m-d', strtotime($m[1].'-W'.$m[2].'-1'));
|
||||
}
|
||||
|
||||
return date('Y-m-d');
|
||||
}
|
||||
|
||||
@@ -571,14 +580,15 @@ class ViolationRuleEngineService
|
||||
|
||||
if (empty($activeWeekKeys)) {
|
||||
$days = ($windowWeeks * 7) - 1;
|
||||
return date('Y-m-d', strtotime($endBound . ' -' . $days . ' days'));
|
||||
|
||||
return date('Y-m-d', strtotime($endBound.' -'.$days.' days'));
|
||||
}
|
||||
|
||||
$activeWeekKeys = array_values($activeWeekKeys);
|
||||
$weekIndex = array_flip($activeWeekKeys);
|
||||
$endWeekKey = date('o-\WW', strtotime($endBound));
|
||||
|
||||
if (!isset($weekIndex[$endWeekKey])) {
|
||||
if (! isset($weekIndex[$endWeekKey])) {
|
||||
$endWeekKey = null;
|
||||
for ($i = count($activeWeekKeys) - 1; $i >= 0; $i--) {
|
||||
$wkStart = $this->isoWeekStartYmd($activeWeekKeys[$i]);
|
||||
@@ -662,11 +672,12 @@ class ViolationRuleEngineService
|
||||
|
||||
while ($iL2 < count($L)) {
|
||||
$windowStart = $L[$iL1];
|
||||
$windowEnd = $windowStart + ($w - 1);
|
||||
$windowEnd = $windowStart + ($w - 1);
|
||||
|
||||
if ($L[$iL2] > $windowEnd) {
|
||||
$iL1++;
|
||||
$iL2 = $iL1 + 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -687,4 +698,4 @@ class ViolationRuleEngineService
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user