diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index a5b257d..9fc045b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -36,6 +36,31 @@ class HomeController extends Controller $categories = Information::CATEGORIES; if (Auth::check()) { + // チェックイン動向グラフ用のデータ取得 + $groupByDay = Ejaculation::select(DB::raw( + <<<'SQL' +to_char(ejaculated_date, 'YYYY/MM/DD') AS "date", +count(*) AS "count" +SQL + )) + ->join('users', function ($join) { + $join->on('users.id', '=', 'ejaculations.user_id') + ->where('users.accept_analytics', true); + }) + ->where('ejaculated_date', '>=', now()->subDays(14)) + ->groupBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')")) + ->orderBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')")) + ->get() + ->mapWithKeys(function ($item) { + return [$item['date'] => $item['count']]; + }); + $globalEjaculationCounts = []; + $day = Carbon::now()->subDays(29); + for ($i = 0; $i < 30; $i++) { + $globalEjaculationCounts[$day->format('Y/m/d') . ' の総チェックイン数'] = $groupByDay[$day->format('Y/m/d')] ?? 0; + $day->addDay(); + } + // お惣菜コーナー用のデータ取得 $publicLinkedEjaculations = Ejaculation::join('users', 'users.id', '=', 'ejaculations.user_id') ->where('users.is_protected', false) @@ -47,7 +72,7 @@ class HomeController extends Controller ->take(10) ->get(); - return view('home')->with(compact('informations', 'categories', 'publicLinkedEjaculations')); + return view('home')->with(compact('informations', 'categories', 'globalEjaculationCounts', 'publicLinkedEjaculations')); } else { return view('guest')->with(compact('informations', 'categories')); } diff --git a/public/css/tissue.css b/public/css/tissue.css index 8394469..e71b920 100644 --- a/public/css/tissue.css +++ b/public/css/tissue.css @@ -24,6 +24,16 @@ transition: filter .15s liner; } +.list-group-item.no-side-border { + border-left: none; + border-right: none; + border-radius: 0; +} + +.list-group-item.border-bottom-only:first-child { + border-top: none; +} + .list-group-item.border-bottom-only { border-left: none; border-right: none; @@ -36,4 +46,15 @@ .timeline-action-item { margin-left: 16px; +} + +.tis-global-count-graph { + height: 90px; + border-bottom: 1px solid rgba(0, 0, 0, .125); +} + +@media (min-width: 992px) { + .tis-sidebar-info { + font-size: small; + } } \ No newline at end of file diff --git a/public/js/tissue.js b/public/js/tissue.js new file mode 100644 index 0000000..dab7c34 --- /dev/null +++ b/public/js/tissue.js @@ -0,0 +1,49 @@ +// app.jsの名はモジュールバンドラーを投入する日まで予約しておく。CSSも同じ。 + +(function ($) { + + $.fn.linkCard = function (options) { + var settings = $.extend({ + endpoint: '/api/checkin/card' + }, options); + + return this.each(function () { + var $this = $(this); + $.ajax({ + url: settings.endpoint, + method: 'get', + type: 'json', + data: { + url: $this.find('a').attr('href') + } + }).then(function (data) { + var $title = $this.find('.card-title'); + var $desc = $this.find('.card-text'); + var $image = $this.find('img'); + + if (data.title === '') { + $title.hide(); + } else { + $title.text(data.title); + } + + if (data.description === '') { + $desc.hide(); + } else { + $desc.text(data.description); + } + + if (data.image === '') { + $image.hide(); + } else { + $image.attr('src', data.image); + } + + if (data.title !== '' || data.description !== '' || data.image !== '') { + $this.removeClass('d-none'); + } + }); + }); + }; + +})(jQuery); \ No newline at end of file diff --git a/resources/views/ejaculation/show.blade.php b/resources/views/ejaculation/show.blade.php index 4a55930..b61cf00 100644 --- a/resources/views/ejaculation/show.blade.php +++ b/resources/views/ejaculation/show.blade.php @@ -112,42 +112,8 @@ form.submit(); }); - $('.link-card').each(function () { - var $this = $(this); - $.ajax({ - url: '{{ url('/api/checkin/card') }}', - method: 'get', - type: 'json', - data: { - url: $this.find('a').attr('href') - } - }).then(function (data) { - var $title = $this.find('.card-title'); - var $desc = $this.find('.card-text'); - var $image = $this.find('img'); - - if (data.title === '') { - $title.hide(); - } else { - $title.text(data.title); - } - - if (data.description === '') { - $desc.hide(); - } else { - $desc.text(data.description); - } - - if (data.image === '') { - $image.hide(); - } else { - $image.attr('src', data.image); - } - - if (data.title !== '' || data.description !== '' || data.image !== '') { - $this.removeClass('d-none'); - } - }); + $('.link-card').linkCard({ + endpoint: '{{ url('/api/checkin/card') }}' }); @endpush \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 3ebad66..eb55241 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -27,120 +27,122 @@ @endcomponent - -
サイトからのお知らせ
- - @if (!empty($publicLinkedEjaculations)) -
-
お惣菜コーナー
-
-

最近の公開チェックインから、オカズリンク付きのものを表示しています。

-
- +
+
+ @if (!empty($globalEjaculationCounts)) +
チェックインの動向
+
+
@endif + @if (!empty($publicLinkedEjaculations)) +
お惣菜コーナー
+

最近の公開チェックインから、オカズリンク付きのものを表示しています。

+ + @endif
@endsection @push('script') + @endpush \ No newline at end of file diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index d2a7af6..de1d1e7 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -134,6 +134,7 @@ + @endpush \ No newline at end of file diff --git a/resources/views/user/profile.blade.php b/resources/views/user/profile.blade.php index 5a674fc..4e442ca 100644 --- a/resources/views/user/profile.blade.php +++ b/resources/views/user/profile.blade.php @@ -136,42 +136,8 @@ form.submit(); }); - $('.link-card').each(function () { - var $this = $(this); - $.ajax({ - url: '{{ url('/api/checkin/card') }}', - method: 'get', - type: 'json', - data: { - url: $this.find('a').attr('href') - } - }).then(function (data) { - var $title = $this.find('.card-title'); - var $desc = $this.find('.card-text'); - var $image = $this.find('img'); - - if (data.title === '') { - $title.hide(); - } else { - $title.text(data.title); - } - - if (data.description === '') { - $desc.hide(); - } else { - $desc.text(data.description); - } - - if (data.image === '') { - $image.hide(); - } else { - $image.attr('src', data.image); - } - - if (data.title !== '' || data.description !== '' || data.image !== '') { - $this.removeClass('d-none'); - } - }); + $('.link-card').linkCard({ + endpoint: '{{ url('/api/checkin/card') }}' }); @endpush \ No newline at end of file