Merge pull request #204 from shikorism/feature/average-range-limit
平均記録を直近30チェックインから算出するように変更
This commit is contained in:
commit
94cabdc827
@ -35,9 +35,27 @@ class ProfileStatsComposer
|
||||
}
|
||||
|
||||
// 概況欄のデータ取得
|
||||
$average = DB::select(<<<'SQL'
|
||||
SELECT
|
||||
avg(span) AS average
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
extract(epoch from ejaculated_date - lead(ejaculated_date, 1, NULL) OVER (ORDER BY ejaculated_date DESC)) AS span
|
||||
FROM
|
||||
ejaculations
|
||||
WHERE
|
||||
user_id = :user_id
|
||||
ORDER BY
|
||||
ejaculated_date DESC
|
||||
LIMIT
|
||||
30
|
||||
) AS temp
|
||||
SQL
|
||||
, ['user_id' => $user->id]);
|
||||
|
||||
$summary = DB::select(<<<'SQL'
|
||||
SELECT
|
||||
avg(span) AS average,
|
||||
max(span) AS longest,
|
||||
min(span) AS shortest,
|
||||
sum(span) AS total_times,
|
||||
@ -56,6 +74,6 @@ FROM
|
||||
SQL
|
||||
, ['user_id' => $user->id]);
|
||||
|
||||
$view->with(compact('latestEjaculation', 'currentSession', 'summary'));
|
||||
$view->with(compact('latestEjaculation', 'currentSession', 'average', 'summary'));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
@endif
|
||||
|
||||
<h6 class="font-weight-bold"><span class="oi oi-graph"></span> 概況</h6>
|
||||
<p class="card-text mb-0">平均記録: {{ Formatter::formatInterval($summary[0]->average) }}</p>
|
||||
<p class="card-text mb-0">平均記録: {{ Formatter::formatInterval($average[0]->average) }}</p>
|
||||
<p class="card-text mb-0">最長記録: {{ Formatter::formatInterval($summary[0]->longest) }}</p>
|
||||
<p class="card-text mb-0">最短記録: {{ Formatter::formatInterval($summary[0]->shortest) }}</p>
|
||||
<p class="card-text mb-0">合計時間: {{ Formatter::formatInterval($summary[0]->total_times) }}</p>
|
||||
|
Loading…
Reference in New Issue
Block a user