From f24f8652bf7b82ba36826907aaac2fc4805bfbaf Mon Sep 17 00:00:00 2001 From: MufridaFaraDiani27 Date: Thu, 21 May 2026 11:00:59 +0700 Subject: [PATCH] pindah periode --- app/Http/Controllers/DashboardController.php | 31 ++- .../Controllers/RekomendasiController.php | 13 +- app/Http/Controllers/UlasanController.php | 6 +- app/Http/Controllers/UserController.php | 4 +- resources/views/analisis/index.blade.php | 80 +------- resources/views/auth/login.blade.php | 13 ++ resources/views/dashboard.blade.php | 70 ++++--- .../scraping_pipeline.cpython-312.pyc | Bin 37029 -> 43273 bytes scraper/redistribute_periode.py | 193 ++++++++++++++++++ scraper/scraping_pipeline.py | 60 ++++-- 10 files changed, 315 insertions(+), 155 deletions(-) create mode 100644 scraper/redistribute_periode.py diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index ece5381..e70dcbd 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -158,15 +158,28 @@ public function index(Request $request) // ================================================================ // CHART DATA // ================================================================ - $chartSentimen = $hasAnalisis - ? DB::table('hasil_analisis') - ->select('sentimen', DB::raw('count(*) as total')) - ->when($periodeId, fn($q) => $q->where('periode_id', $periodeId)) - ->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata)) - ->groupBy('sentimen') - ->orderByRaw("FIELD(sentimen, 'positif', 'negatif', 'netral')") - ->get() - : collect(); + // $chartSentimen = $hasAnalisis + // ? DB::table('hasil_analisis') + // ->select('sentimen', DB::raw('count(*) as total')) + // ->when($periodeId, fn($q) => $q->where('periode_id', $periodeId)) + // ->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata)) + // ->groupBy('sentimen') + // ->orderByRaw("FIELD(sentimen, 'positif', 'negatif', 'netral')") + // ->get() + // : collect(); + + $rawSentimen = DB::table('hasil_analisis') + ->select('sentimen', DB::raw('count(*) as total')) + ->when($periodeId, fn($q) => $q->where('periode_id', $periodeId)) + ->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata)) + ->groupBy('sentimen') + ->pluck('total', 'sentimen'); + + $chartSentimen = collect([ + ['sentimen' => 'positif', 'total' => $rawSentimen['positif'] ?? 0], + ['sentimen' => 'negatif', 'total' => $rawSentimen['negatif'] ?? 0], + ['sentimen' => 'netral', 'total' => $rawSentimen['netral'] ?? 0], + ]); $chartDestinasi = $hasAnalisis ? DB::table('hasil_analisis') diff --git a/app/Http/Controllers/RekomendasiController.php b/app/Http/Controllers/RekomendasiController.php index 9a3eb05..4e81d55 100644 --- a/app/Http/Controllers/RekomendasiController.php +++ b/app/Http/Controllers/RekomendasiController.php @@ -22,7 +22,7 @@ class RekomendasiController extends Controller 'tip' => 'Tambah tempat sampah & jadwal pembersihan rutin.', ], ], - 'Parkir' => [ + 'Aksesibilitas' => [ 'keywords' => ['parkir', 'lahan parkir', 'tempat parkir', 'parkiran', 'motor', 'mobil'], 'color' => 'orange', 'icon' => '🚗', @@ -52,16 +52,7 @@ class RekomendasiController extends Controller 'tip' => 'Fasilitas lengkap & terawat meningkatkan kepuasan.', ], ], - 'Keramaian' => [ - 'keywords' => ['ramai', 'macet', 'antri', 'sesak', 'penuh', 'padat', 'berdesakan'], - 'color' => 'blue', - 'icon' => '👥', - 'saran' => [ - 'actions' => ['Atur kapasitas pengunjung', 'Sistem antrean', 'Jam kunjungan fleksibel'], - 'dampak' => 'Pengalaman pengunjung lebih nyaman', - 'tip' => 'Manajemen kapasitas pengunjung lebih baik.', - ], - ], + ]; public function index(Request $request) diff --git a/app/Http/Controllers/UlasanController.php b/app/Http/Controllers/UlasanController.php index 78ca94a..9b5add4 100644 --- a/app/Http/Controllers/UlasanController.php +++ b/app/Http/Controllers/UlasanController.php @@ -24,13 +24,15 @@ public function index(Request $request) ->from('hasil_analisis as h') ->whereColumn('h.periode_id', 'p.id'); }) - ->orderBy('p.id', 'desc') + ->orderBy('p.tahun', 'desc') + ->orderBy('p.bulan', 'desc') + // ->orderBy('p.id', 'desc') ->select('p.*') ->get(); $availablePeriodeIds = $periodeList->pluck('id')->map(fn($id) => (string) $id); $requestedPeriodeId = $request->filled('periode_id') ? (string) $request->periode_id : null; - $latestFilledPeriodeId = $periodeList->first()->id ?? null; + $latestFilledPeriodeId = $periodeList->sortByDesc('id')->first()->id ?? null; $periodeId = $request->filled('periode_id') && $availablePeriodeIds->contains($requestedPeriodeId) ? $requestedPeriodeId diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index f2420ea..6aed363 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -110,14 +110,14 @@ public function store(Request $request) 'password' => 'required|min:8|confirmed', ]); - User::create([ + User::create([ 'name' => $request->name, 'email' => $request->email, 'role' => $request->role, 'password' => bcrypt($request->password), ]); - return redirect()->route('kelola-pengguna.index') + return redirect()->route('kelola-pengguna.index') ->with('success', 'Pengguna berhasil ditambahkan.'); } } \ No newline at end of file diff --git a/resources/views/analisis/index.blade.php b/resources/views/analisis/index.blade.php index 2a7ca9b..a775274 100644 --- a/resources/views/analisis/index.blade.php +++ b/resources/views/analisis/index.blade.php @@ -59,85 +59,7 @@ - {{-- ================= MATRIX + PERFORMA ================= --}} -
- - {{-- CONFUSION MATRIX --}} -
-

Confusion Matrix

-

- Kolom tp/tn/fp/fn sederhana tidak representatif untuk 3 kelas, sehingga disimpan 0. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PositifNegatifNetral
Positif{{ $evaluasi->tp ?? 0 }}{{ $evaluasi->fp ?? 0 }}{{ $evaluasi->fn ?? 0 }}
Negatif{{ $evaluasi->fp ?? 0 }}{{ $evaluasi->tn ?? 0 }}0
Netral000
-
- - {{-- PERFORMA --}} -
-

Performa per Kelas

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KelasPrecisionRecallF1
Positif{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}
Negatif{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}
Netral{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}
-
- -
+ {{-- ================= FILTER ================= --}}
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 03d305b..90d879c 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -288,6 +288,19 @@ + @if ($errors->any()) + + + + @endif +
Selamat Datang Kembali!
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 3b1459b..5399b4d 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -8,7 +8,7 @@ @if(session('success'))
{{ session('success') }} -
+ @endif @if(session('error'))
@@ -63,11 +63,14 @@ class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]">
-
+ +
-