From 9dbf8eee7d7ac1a5ce5c4b6bcaee373c7a3ba3ed Mon Sep 17 00:00:00 2001 From: Agung Sugiarto Date: Thu, 22 Jun 2023 08:18:13 +0700 Subject: [PATCH] [bug] perbaiki issue #165 dan #166 (#167) --- app/Models/Desa.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/Models/Desa.php b/app/Models/Desa.php index b309a8d4..c03b6521 100644 --- a/app/Models/Desa.php +++ b/app/Models/Desa.php @@ -59,9 +59,7 @@ public function scopeJumlahDesa($query) $versi_opensid = lastrelease('https://api.github.com/repos/OpenSID/rilis-premium/releases/latest'); if ($versi_opensid !== false) { - $version = $versi_opensid->tag_name; - $version = preg_replace('/[^0-9]/', '', $version); - $version = substr($version, 0, 2).'.'.substr($version, 2, 2); + $version = str_replace('v', '', $versi_opensid->tag_name); } if ($provinsi = session('provinsi')) { @@ -73,7 +71,7 @@ public function scopeJumlahDesa($query) ->selectRaw("(select count(id) from desa as x where x.versi_lokal <> '' and x.versi_hosting is null and coalesce(x.tgl_akses_lokal, 0) >= now() - interval 7 day {$states}) desa_offline") ->selectRaw("(select count(id) from desa as x where x.versi_hosting <> '' and greatest(coalesce(x.tgl_akses_lokal, 0), coalesce(x.tgl_akses_hosting, 0)) >= now() - interval 7 day {$states}) desa_online") ->selectRaw('count(distinct kode_kabupaten) as kabupaten_total') - ->selectRaw("(select count(distinct x.kode_kabupaten) from desa as x where (x.versi_hosting LIKE '{$version}-premium%' Or x.versi_lokal LIKE '{$version}-premium%') {$states} ) as kabupaten_premium") + ->selectRaw("(select count(distinct x.kode_kabupaten) from desa as x where (x.versi_hosting like '{$version}-premium%' or x.versi_lokal like '{$version}-premium%') {$states} ) as kabupaten_premium") ->selectRaw("(select count(distinct x.kode_kabupaten) from desa as x where x.versi_lokal <> '' {$states}) kabupaten_offline") ->selectRaw("(select count(distinct x.kode_kabupaten) from desa as x where x.versi_hosting <> '' {$states}) kabupaten_online") ->selectRaw("(select count(id) from desa as x where x.jenis = 2 {$states}) bukan_desa") @@ -173,12 +171,10 @@ public function scopeKabupatenOpenSID($query, $fillters = []) $versi_opensid = lastrelease('https://api.github.com/repos/OpenSID/rilis-premium/releases/latest'); if ($versi_opensid !== false) { - $version = $versi_opensid->tag_name; - $version = preg_replace('/[^0-9]/', '', $version); - $version = substr($version, 0, 2).'.'.substr($version, 2, 2); + $version = str_replace('v', '', $versi_opensid->tag_name); - $query->where('d.versi_hosting', 'LIKE', $version.'-premium%') - ->orWhere('d.versi_lokal', 'LIKE', $version.'-premium%'); + $query->where('d.versi_hosting', 'like', "{$version}-premium%") + ->orWhere('d.versi_lokal', 'like', "{$version}-premium%"); } }); }, 'sub')