Merge pull request #166 from shikorism/fix/exclude-future-checkin-from-stats

グラフ画面で表示するデータ範囲を当月末までに制限
This commit is contained in:
shibafu 2019-03-31 09:55:40 +09:00 committed by GitHub
commit 212fad4d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,6 +67,8 @@ SQL
abort(404);
}
$dateUntil = now()->addMonth()->startOfMonth();
$groupByDay = Ejaculation::select(DB::raw(
<<<'SQL'
to_char(ejaculated_date, 'YYYY/MM/DD') AS "date",
@ -74,6 +76,7 @@ count(*) AS "count"
SQL
))
->where('user_id', $user->id)
->where('ejaculated_date', '<', $dateUntil)
->groupBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')"))
->orderBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')"))
->get();
@ -85,6 +88,7 @@ count(*) AS "count"
SQL
))
->where('user_id', $user->id)
->where('ejaculated_date', '<', $dateUntil)
->groupBy(DB::raw("to_char(ejaculated_date, 'HH24')"))
->orderBy(DB::raw('1'))
->get();