fix logic and tests, update docker CI file
This commit is contained in:
@@ -91,7 +91,7 @@ class ClassPreparationCalculatorService
|
||||
$qty = $isLowerGrades ? 0 : $students;
|
||||
break;
|
||||
case 'teacher chair':
|
||||
$qty = (int) $teacherCount;
|
||||
$qty = $teacherCount > 0 ? (int) $teacherCount : 1;
|
||||
break;
|
||||
case 'trash bin':
|
||||
case 'white board':
|
||||
@@ -114,13 +114,22 @@ class ClassPreparationCalculatorService
|
||||
{
|
||||
$schoolYear = $schoolYear ?: (string) Configuration::getConfig('school_year');
|
||||
|
||||
$row = DB::table('teacher_class')
|
||||
$baseQuery = DB::table('teacher_class')
|
||||
->select('COUNT(*) AS cnt')
|
||||
->where('class_section_id', $classSectionId)
|
||||
->whereIn('position', ['main', 'ta'])
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
->whereIn('position', ['main', 'ta']);
|
||||
|
||||
return (int) ($row->cnt ?? 0);
|
||||
$row = $schoolYear !== null && $schoolYear !== ''
|
||||
? (clone $baseQuery)->where('school_year', $schoolYear)->first()
|
||||
: $baseQuery->first();
|
||||
|
||||
$count = (int) ($row->cnt ?? 0);
|
||||
|
||||
if ($count === 0 && $schoolYear !== null && $schoolYear !== '') {
|
||||
$row = $baseQuery->first();
|
||||
$count = (int) ($row->cnt ?? 0);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user