Commit 0c4a77f4 authored by Jack Stupple's avatar Jack Stupple

return resources the user would be recommended on recommendations endpoint

parent de3bf044
......@@ -40,8 +40,18 @@ class ResourceController extends Controller
{
$recommended_query = $this->buildRecommendedQuery(get_player());
$bad_answers = $this->getBaseSubquery()->whereRaw('answers.weight < 0.5');
$good_answers = $this->getBaseSubquery()->whereRaw('answers.weight >= 0.5');
// used primarily for debugging
$resource_categories = \App\ResourceCategory::select(['id', 'name'])
->whereRaw('id IN (' . $bad_answers->toSql() . ')')
->whereRaw('id NOT IN (' . $good_answers->toSql() . ')')
->get();
return [
'count' => $recommended_query ? $recommended_query->count() : null,
'resource_categories' => $resource_categories,
'recommended' => $recommended_query ? $recommended_query->get() : []
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment