BestSolution   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 18
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 16 1
1
<?php
2
3
namespace App\Repositories\Criteria;
4
5
use Czim\Repository\Contracts\BaseRepositoryInterface;
6
use Czim\Repository\Contracts\CriteriaInterface;
7
8
class BestSolution implements CriteriaInterface
9
{
10
    public function apply($model, BaseRepositoryInterface $repository)
11
    {
12
        app('db')->connection()->statement('SET sql_mode = \'\'');
13
        $rawCount = 'count(*) as att';
14
        $rawGrade = 'min(10000000000000000000 + time_cost * 100000000000 + memory_cost * 100000) as score';
15
16
        return $model->select(
17
            'id',
18
            'problem_id',
19
            'user_id',
20
            'language',
21
            'memory_cost',
22
            'time_cost',
23
            'created_at',
24
            app('db')->raw($rawCount),
25
            app('db')->raw($rawGrade)
26
        );
27
    }
28
}
29