diff --git a/app/Http/Controllers/FrontIndexController.php b/app/Http/Controllers/FrontIndexController.php index 4e92fef..dbb7060 100644 --- a/app/Http/Controllers/FrontIndexController.php +++ b/app/Http/Controllers/FrontIndexController.php @@ -37,7 +37,7 @@ class FrontIndexController extends Controller $raw = DB::select("SELECT * FROM searchlocations(?)", [$terms]); $results = []; foreach ($raw as $item) { - if ($item->block_count > 2) { + if (($item->block_count + $item->silence_count) > 2) { array_push($results, $item); } } @@ -46,6 +46,7 @@ class FrontIndexController extends Controller $count = count($locations); $recent = Location::where("active", true) ->where('block_count', '>', 2) + ->where('silence_count', '>', 2) ->limit(10)->orderByDesc('updated_at')->get(); return view('front.index', [ @@ -68,15 +69,18 @@ class FrontIndexController extends Controller public function location(string $uuid = "1") { $location = Location::where("uuid", $uuid)->first(); + $sources = Source::where("active", true)->get(); $name = "NO LOCATION FOUND"; if ($location) { $name = $location->name; } return view('front.location', [ - 'title' => str_replace(".", " ", $name), - 'location' => $location, - 'images' => json_decode($location->images), - 'updated' => $location->updated_at->format('Y M d'), + 'title' => str_replace(".", " ", $name), + 'location' => $location, + 'actions' => $location->block_count + $location->silence_count, + 'sources_count' => count($sources), + 'images' => json_decode($location->images), + 'updated' => $location->updated_at->format('Y M d'), ]); } diff --git a/app/Http/Controllers/LocationController.php b/app/Http/Controllers/LocationController.php index baeaff5..51d8ada 100644 --- a/app/Http/Controllers/LocationController.php +++ b/app/Http/Controllers/LocationController.php @@ -72,14 +72,26 @@ class LocationController extends Controller $index = array_search($item['domain'], array_column($unified, 'url')); if ($index) { //if there is a match, update the count - ++$unified[$index]['count']; + if ($item['severity'] == "suspend" || $item['severity'] == "defederate") { + ++$unified[$index]['block_count']; + } else { + ++$unified[$index]['silence_count']; + } } else { + $silence = 0; + $suspend = 0; + if ($item['severity'] == "suspend" || $item['severity'] == "defederate") { + ++$silence; + } else { + ++$suspend; + } array_push($unified, [ - 'name' => $item['domain'], - 'url' => $item['domain'], - 'rating' => $item['severity'], - 'comment' => $item['comment'], - 'count' => 1, + 'name' => $item['domain'], + 'url' => $item['domain'], + 'rating' => $item['severity'], + 'comment' => $item['comment'], + 'block_count' => $suspend, + 'silence_count' => $silence, ]); } } @@ -91,14 +103,26 @@ class LocationController extends Controller $index = array_search($item[0], array_column($unified, 'url')); if ($index) { //if there is a match, update the count - ++$unified[$index]['count']; + if ($item[1] == "suspend" || $item['severity'] == "defederate") { + ++$unified[$index]['block_count']; + } else { + ++$unified[$index]['silence_count']; + } } else { + $silence = 0; + $suspend = 0; + if ($item[1] == "suspend" || $item[1] == "defederate") { + ++$silence; + } else { + ++$suspend; + } array_push($unified, [ - 'name' => $item[0], - 'url' => $item[0], - 'rating' => $item[1], - 'comment' => $item[2], - 'count' => 1, + 'name' => $item[0], + 'url' => $item[0], + 'rating' => $item[1], + 'comment' => $item[2], + 'block_count' => $suspend, + 'silence_count' => $silence, ]); } } @@ -137,7 +161,8 @@ class LocationController extends Controller ++$duplicates; //update block count for existing item - $location->block_count = $item['count']; + $location->block_count = $item['block_count']; + $location->silence_count = $item['silence_count']; //replace null with empty array if ($location->images == null) { @@ -150,16 +175,17 @@ class LocationController extends Controller $images = []; $rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating']; $new = Location::create([ - 'uuid' => Uuid::uuid4(), - 'name' => $item['url'], - 'url' => $item['url'], - 'description' => ($item['comment'] != null) ? $item['comment'] : "no description", - 'active' => true, - 'rating' => $rating, - 'added_by' => 1, - 'tags' => 'poor moderation, hate speech', - 'images' => json_encode($images), - 'block_count' => $item['count'], + 'uuid' => Uuid::uuid4(), + 'name' => $item['url'], + 'url' => $item['url'], + 'description' => ($item['comment'] != null) ? $item['comment'] : "no description", + 'active' => true, + 'rating' => $rating, + 'added_by' => 1, + 'tags' => 'poor moderation, hate speech', + 'images' => json_encode($images), + 'block_count' => $item['block_count'], + 'silence_count' => $item['silence_count'], ]); } } diff --git a/public/assets/css/front/listing.css b/public/assets/css/front/listing.css index 8034739..bca702e 100644 --- a/public/assets/css/front/listing.css +++ b/public/assets/css/front/listing.css @@ -37,7 +37,7 @@ section[role="listings"] div[role="paginate"] span { a.list-link { display: grid; - grid-template-columns: 30px 50px 300px; + grid-template-columns: 30px 50px 30px 50px 300px; width: 80%; height: 45px; } diff --git a/resources/views/front/index.blade.php b/resources/views/front/index.blade.php index cdc032e..b9be73c 100644 --- a/resources/views/front/index.blade.php +++ b/resources/views/front/index.blade.php @@ -32,11 +32,9 @@ @foreach($recent as $location) {{$location->block_count}} - @if($location->rating == 'silence') - - @else - - @endif + + {{$location->silence_count}} + @endforeach diff --git a/resources/views/front/location.blade.php b/resources/views/front/location.blade.php index cad5f39..5ce19fe 100644 --- a/resources/views/front/location.blade.php +++ b/resources/views/front/location.blade.php @@ -17,16 +17,14 @@ @endforeach @endif
- @if($location->rating == 'silence') - - Silenced Count: {{$location->block_count}} - @else - - Suspended Count: {{$location->block_count}} + Total Actions: {{$actions}}/{{$sources_count}}
+ + Suspended: {{$location->block_count}} - @endif -
- This count reflects the number of times this instance has been suspended or silenced be two or more Current Sources + + Silenced: {{$location->silence_count}} +

+ Total Actions represent the number of actions, silences or suspensions, that have been taken against an instance by Current Sources
UPDATED : {{$updated}}