Skip to content

Commit

Permalink
Merge pull request #223 from fznoviar/issue-221
Browse files Browse the repository at this point in the history
Resolved #221 
Change overall error rate score calculation
  • Loading branch information
wicochandra committed Jan 25, 2016
2 parents e4cfefd + f6f9ba5 commit 212a085
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Supports/CalculateScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function calculate(Inspection $inspection)
{
foreach ($inspection->scopeList as $category) {
$uniqueUrlInIssues = $inspection->issues()->byCategorySlug($category->slug)->error()->distinct()
->select('url')->get()
->select(['url', 'scope_id'])->get()
->count();
$uniqueUrlInJobs = $inspection->jobInspects()->byCategorySlug($category->slug)->distinct()
->select(['url_id', 'scope_id'])->get()
Expand All @@ -49,7 +49,10 @@ public function calculate(Inspection $inspection)
$score->save();
}

$overallErrorRate = $inspection->scores()->sum('score') / $inspection->scopeList->count();
$alUniqueUrlInIssues = $inspection->issues()->error()->distinct()->select(['url', 'scope_id'])->get()->count();
$alUniqueUrlInJobs = $inspection->jobInspects()->distinct()->select(['url_id', 'scope_id'])->get()->count();
$overallErrorRate = $alUniqueUrlInIssues / $alUniqueUrlInJobs;

$inspection->update(['status' => 2, 'score' => round($overallErrorRate, 2)]);
}
}

0 comments on commit 212a085

Please sign in to comment.