Skip to content

Commit

Permalink
Merge branch 'main' into ifkar
Browse files Browse the repository at this point in the history
  • Loading branch information
IfkarArfianQ authored Dec 16, 2024
2 parents 3a98f80 + 406e0c2 commit e254b24
Show file tree
Hide file tree
Showing 34 changed files with 288 additions and 218 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Laravel CD

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /var/www/app-monitoring
git pull origin main
composer install --no-interaction --prefer-dist --optimize-autoloader
php artisan config:clear
37 changes: 37 additions & 0 deletions .github/workflows/ci_code_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Fix Code Style

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.3]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install Pint
run: composer global require laravel/pint

- name: Run Pint
run: pint

- name: Commit linted files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Fixes coding style"
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected function schedule(Schedule $schedule)
{
$hour = config('app.hour');
$min = config('app.min');
$scheduledInterval = $hour !== '' ? (($min !== '' && $min != 0) ? $min . ' */' . $hour . ' * * *' : '0 */' . $hour . ' * * *') : '*/' . $min . ' * * * *';
$scheduledInterval = $hour !== '' ? (($min !== '' && $min != 0) ? $min.' */'.$hour.' * * *' : '0 */'.$hour.' * * *') : '*/'.$min.' * * * *';
if (config('app.is_demo')) {
$schedule->command('migrate:fresh --seed')->cron($scheduledInterval);
}
Expand All @@ -25,7 +25,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
Expand Down
9 changes: 7 additions & 2 deletions app/Http/Controllers/AktivitasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Aktivitas;
use Illuminate\Http\Request;

class AktivitasController extends Controller
{
public function index() {
public function index()
{
$aktivitas = Aktivitas::all();

return view('pembimbing.aktivitas', compact('aktivitas'));
}

Expand All @@ -24,11 +26,14 @@ public function store(Request $request)

return redirect()->route('aktivitas.index')->with('success', 'Aktivitas berhasil ditambahkan.');
}

public function edit($id)
{
$aktivitas = Aktivitas::findOrFail($id);

return view('pembimbing.edit_aktivitas', compact('aktivitas'));
}

public function update(Request $request, $id)
{
$request->validate([
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function create()
public function store(Request $request)
{
if (config('app.is_demo')) {
return back()->with('error', "You are in a demo version, resetting password is disabled.");
return back()->with('error', 'You are in a demo version, resetting password is disabled.');
}

$request->validate([
Expand All @@ -33,6 +33,6 @@ public function store(Request $request)
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
->withErrors(['email' => __($status)]);
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
Expand Down Expand Up @@ -45,13 +45,13 @@ public function store(Request $request)

return back()->withErrors(['message' => 'Username atau password salah.'])->withInput($request->only('username'));
}


public function destroy(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();

return redirect('/sign-in');
}
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class ResetPasswordController extends Controller
{

public function create(Request $request)
{
return view('auth.passrecover.reset-password', ['request' => $request]);
Expand Down Expand Up @@ -46,6 +45,6 @@ function ($user) use ($request) {
return $status == Password::PASSWORD_RESET
? redirect()->route('sign-in')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
->withErrors(['email' => __($status)]);
}
}
51 changes: 25 additions & 26 deletions app/Http/Controllers/DashboardPembimbingController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Siswa;
use App\Models\Materi;
use App\Models\Aktivitas;
use App\Models\Siswa;
use Carbon\Carbon;

class DashboardPembimbingController extends Controller
Expand All @@ -21,8 +20,8 @@ public function index()
'data' => [$rplCount, $tkjCount],
'backgroundColor' => ['#36A2EB', '#FF6384'],
'hoverOffset' => 15,
]
]
],
],
];

$activityData = Siswa::select('kategori')
Expand All @@ -35,33 +34,33 @@ public function index()
->groupBy('kategori')
->pluck('total_waktu', 'kategori');

$jumlahDataRPL = Siswa::where('user_id')
$jumlahDataRPL = Siswa::where('user_id')
->whereIn('kategori', ['Dikantor', 'Keluar Dengan Teknisi'])
->count();


$jumlahDataTKJ = Siswa::where('user_id')
$jumlahDataTKJ = Siswa::where('user_id')
->whereIn('kategori', ['Learning', 'Project'])
->count();

$totalWaktu = Siswa::where('user_id')
->get()
->reduce(function ($carry, $item) {
if ($item->waktu_mulai && $item->waktu_selesai) {
$waktuMulai = Carbon::parse($item->waktu_mulai);
$waktuSelesai = Carbon::parse($item->waktu_selesai);
if ($waktuSelesai->greaterThan($waktuMulai)) {
$carry += $waktuSelesai->diffInSeconds($waktuMulai);
}

$totalWaktu = Siswa::where('user_id')
->get()
->reduce(function ($carry, $item) {
if ($item->waktu_mulai && $item->waktu_selesai) {
$waktuMulai = Carbon::parse($item->waktu_mulai);
$waktuSelesai = Carbon::parse($item->waktu_selesai);
if ($waktuSelesai->greaterThan($waktuMulai)) {
$carry += $waktuSelesai->diffInSeconds($waktuMulai);
}
return $carry;
}, 0);

$totalAktivitas = $jumlahDataTKJ + $jumlahDataRPL;

$persentaseTKJ = $totalAktivitas > 0 ? ($jumlahDataTKJ / $totalAktivitas) * 100 : 0;
$persentaseRPL = $totalAktivitas > 0 ? ($jumlahDataRPL / $totalAktivitas) * 100 : 0;
}

return $carry;
}, 0);

$totalAktivitas = $jumlahDataTKJ + $jumlahDataRPL;

$persentaseTKJ = $totalAktivitas > 0 ? ($jumlahDataTKJ / $totalAktivitas) * 100 : 0;
$persentaseRPL = $totalAktivitas > 0 ? ($jumlahDataRPL / $totalAktivitas) * 100 : 0;

return view('dashboard', compact('chartData', 'activityData', 'totalWaktuPerKategori', 'rplCount', 'tkjCount','jumlahDataRPL','jumlahDataTKJ','totalWaktu','persentaseTKJ','persentaseRPL'));
return view('dashboard', compact('chartData', 'activityData', 'totalWaktuPerKategori', 'rplCount', 'tkjCount', 'jumlahDataRPL', 'jumlahDataTKJ', 'totalWaktu', 'persentaseTKJ', 'persentaseRPL'));
}
}
66 changes: 34 additions & 32 deletions app/Http/Controllers/DashboardRplController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Carbon\Carbon;
use App\Models\Siswa;
use App\Models\Materi;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class DashboardRplController extends Controller
Expand All @@ -15,45 +14,47 @@ public function index(Request $request)
$userId = Auth::id();

$totalWaktuLearning = Siswa::where('user_id', $userId)
->where('kategori', 'Learning')
->get()
->reduce(function ($carry, $item) {
if ($item->waktu_mulai && $item->waktu_selesai) {
$waktuMulai = Carbon::parse($item->waktu_mulai);
$waktuSelesai = Carbon::parse($item->waktu_selesai);
if ($waktuSelesai->greaterThan($waktuMulai)) {
$carry += $waktuSelesai->diffInSeconds($waktuMulai);
}
}
return $carry;
}, 0);

$siswaDataLearning = Siswa::where('user_id', $userId)
->where('kategori', 'Learning')
->get()
->groupBy('materi_id')
->map(function ($items, $materiId) use ($totalWaktuLearning) {
$totalTime = 0;
foreach ($items as $item) {
->where('kategori', 'Learning')
->get()
->reduce(function ($carry, $item) {
if ($item->waktu_mulai && $item->waktu_selesai) {
$waktuMulai = Carbon::parse($item->waktu_mulai);
$waktuSelesai = Carbon::parse($item->waktu_selesai);
if ($waktuSelesai->greaterThan($waktuMulai)) {
$totalTime += $waktuSelesai->diffInSeconds($waktuMulai);
$carry += $waktuSelesai->diffInSeconds($waktuMulai);
}
}

return $carry;
}, 0);

$siswaDataLearning = Siswa::where('user_id', $userId)
->where('kategori', 'Learning')
->get()
->groupBy('materi_id')
->map(function ($items, $materiId) use ($totalWaktuLearning) {
$totalTime = 0;
foreach ($items as $item) {
if ($item->waktu_mulai && $item->waktu_selesai) {
$waktuMulai = Carbon::parse($item->waktu_mulai);
$waktuSelesai = Carbon::parse($item->waktu_selesai);
if ($waktuSelesai->greaterThan($waktuMulai)) {
$totalTime += $waktuSelesai->diffInSeconds($waktuMulai);
}
}
}
}
$percentage = $totalWaktuLearning ? ($totalTime / $totalWaktuLearning) * 100 : 0;
return ['totalTime' => $totalTime, 'percentage' => $percentage];
});
$percentage = $totalWaktuLearning ? ($totalTime / $totalWaktuLearning) * 100 : 0;

return ['totalTime' => $totalTime, 'percentage' => $percentage];
});

$materiNamesLearning = Materi::whereIn('id', $siswaDataLearning->keys())->pluck('materi', 'id');

$jumlahAktivitasLearning = Siswa::where('user_id', $userId)
->where('kategori', 'Learning')
->get()
->groupBy('materi_id')
->map->count();
->where('kategori', 'Learning')
->get()
->groupBy('materi_id')
->map->count();

$jumlahDataProject = Siswa::where('user_id', $userId)
->where('kategori', 'Project')
Expand All @@ -74,6 +75,7 @@ public function index(Request $request)
$totalTime = $waktuSelesai->diffInSeconds($waktuMulai);
}
}

return [
'name' => $item->aktivitas_name,
'totalTime' => $totalTime,
Expand Down
Loading

0 comments on commit e254b24

Please sign in to comment.