summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Http/Controllers/AnimeController.php8
-rw-r--r--resources/views/anime.blade.php18
2 files changed, 23 insertions, 3 deletions
diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php
index 662b6cc..32f6556 100644
--- a/app/Http/Controllers/AnimeController.php
+++ b/app/Http/Controllers/AnimeController.php
@@ -71,14 +71,18 @@ class AnimeController extends Controller {
$score_9[] = $stats->score_9;
$score_10[] = $stats->score_10;
+ if ( 0 != $stats->scored_by ) {
+ $calculated_score[] = ($stats->score_1 + (2*$stats->score_2) + (3*$stats->score_3) + (4*$stats->score_4) + (5*$stats->score_5) + (6*$stats->score_6) + (7*$stats->score_7) + (8*$stats->score_8) + (9*$stats->score_9) + (10*$stats->score_10)) / $stats->scored_by;
+ }
+
}
if ( isset($score) ) {
$anime["score"] = $score;
$anime["rank"] = $rank;
-
$anime["chart_label_score"] = $created_at_score;
}
+
$anime["popularity"] = $popularity;
$anime["members"] = $members;
$anime["favorites"] = $favorites;
@@ -102,6 +106,8 @@ class AnimeController extends Controller {
$anime["chart_label"] = $created_at;
+ $anime["calculated_score"] = $calculated_score;
+
$anime["basic_data"] = DB::select('select score, rank, popularity, members, favorites from anime join stats on stats.id = ( select id from stats where anime.mal_id = stats.mal_id order by created_at desc limit 1) where anime.mal_id = ?', [$mal_id])[0];
return view('anime', [ "anime" => $anime ]);
diff --git a/resources/views/anime.blade.php b/resources/views/anime.blade.php
index 0d00cb4..804603c 100644
--- a/resources/views/anime.blade.php
+++ b/resources/views/anime.blade.php
@@ -59,14 +59,28 @@ new Chart(document.getElementById('score_chart'), {
type: 'line',
data: {
labels: {!! json_encode($anime["chart_label_score"]) !!},
- datasets: [{
+ datasets: [
+ {
label: 'Average Score on MAL',
data: {!! printScoreData($anime["score"]) !!},
file: 'false',
borderColor: 'rgb(75, 192, 192)',
lineTension: 0.01,
backgroundColor: 'rgb(255,255,255,0)',
- }]
+ }
+
+@if ( \Request::input('showRealScore') )
+ ,{
+ label: 'Real calculated Score',
+ data: {!! printScoreData($anime["calculated_score"]) !!},
+ file: 'false',
+ borderColor: 'grey',
+ lineTension: 0.01,
+ backgroundColor: 'rgb(255,255,255,0)',
+ }
+@endif
+
+ ]
},
options: {
maintainAspectRatio: true,