Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint6 #82

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ public function spotInfo($spotId)
BETWEEN '.$long.' - '.$radius.'/(69 * COS(RADIANS('.$lat.')))
AND '.$long.' + '.$radius.'/(69 * COS(RADIANS('.$lat.'))))r
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What "r" means in the code below ?
AND '.$long.' + '.$radius.'/(69 * COS(RADIANS('.$lat.'))))r

We should ask BlueT.

WHERE `distance` < '. $radius .'
ORDER BY `distance` ASC');
return response()->json([
'item' => $spotInfo,
'comment' => $spotComment,
'lat' => $lat,
'long' => $long,
// 'location' => $spotLocation,
'Nearby' => $shopNearby,
'commentTotal' => $commentTotal
]);
ORDER BY `distance` ASC'); //radius search raw expression
$avgRate = 0;
foreach ($spotComment as $key => $value) {
if(isset($value->rating))
$avgRate += $value->rating;
} //average rate calculate
return response()->json([
'item' => $spotInfo,
'comment' => $spotComment,
'Nearby' => $shopNearby,
'commentTotal' => $commentTotal,
'avgRate' => $avgRate/$commentTotal
]);
}
}

Expand Down Expand Up @@ -215,12 +218,16 @@ public function shopInfo($shopId)
// $shopLocation = $shopInfo->pluck('location')->first();
// $spotNearBy = Shop::where('location', $shopLocation)->first()->get();
$commentTotal = $shopComment->count();
$avgRate = 0;
foreach ($shopComment as $key => $value) {
if(isset($value->rating))
$avgRate += $value->rating;
} //average rate calculate
return response()->json([
'item' => $shopInfo,
'comment' => $shopComment,
// 'location' => $shopLocation,
// 'shopNearBy' => $spotNearBy
'commentTotal' => $commentTotal
'commentTotal' => $commentTotal,
'avgRate' => $avgRate/$commentTotal
]);
}
}
Expand Down