diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 5dd703b..ec6bcf0 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -2,15 +2,37 @@ namespace App\Http\Controllers; -use App\Models\Location; +use App\Repositories\LocationRepository; use App\Models\Source; class ExportController extends Controller { + protected $locationRepository; + + public function __construct(LocationRepository $locationRepository) + { + $this->locationRepository = $locationRepository; + } + public function exportIndex() { + $heatArray = [90, 80, 70, 60, 50, 40, 30, 20]; + $sources = Source::where("active", true)->get(); + $locations = $this->locationRepository->getActiveLocations(); + $list = []; + foreach ($heatArray as $rating) { + $count = 0; + foreach ($locations as $location) { + $rate = $location->actions_count / count($sources); + if ($rate * 100 >= $rating) { + $count++; + } + } + array_push($list, ["heatRating" => $rating, "ratingCount" => $count]); + } return view('front.exports', [ - 'title' => "Exports" + 'title' => "Exports", + 'list' => $list ]); } @@ -20,7 +42,7 @@ class ExportController extends Controller $columns = []; $list = []; - $locations = Location::where("active", true)->get(); + $locations = $this->locationRepository->getActiveLocations(); $sources = Source::where("active", true)->get(); if ($type == 'mastodon') { $columns = [ @@ -34,20 +56,17 @@ class ExportController extends Controller }; foreach ($locations as $location) { - $total = $location->block_count + $location->silence_count; - if ($total >= 2) { - $rate = $total / count($sources); - if ($rate * 100 >= $percent) { - if ($type == 'mastodon') { - //comman break teh CSV so just take them out - $comments = str_replace(",", ";", $location->description); + $rate = $location->actions_count / count($sources); + if ($rate * 100 >= $percent) { + if ($type == 'mastodon') { + //comman break teh CSV so just take them out + $comments = str_replace(",", ";", $location->description); - //remove extra white space - $comments = str_replace(["\n\r", "\n", "\r"], " ", $comments); - $comments = str_replace(['"', "'"], "", $comments); - //add to the export list - array_push($list, [$location->url, $location->rating, $comments, "FALSE", "FALSE", "FALSE"]); - } + //remove extra white space + $comments = str_replace(["\n\r", "\n", "\r"], " ", $comments); + $comments = str_replace(['"', "'"], "", $comments); + //add to the export list + array_push($list, [$location->url, $location->rating, $comments, "FALSE", "FALSE", "FALSE"]); } } } diff --git a/resources/views/front/exports.blade.php b/resources/views/front/exports.blade.php index 3f0dbb8..6b3f5c5 100644 --- a/resources/views/front/exports.blade.php +++ b/resources/views/front/exports.blade.php @@ -8,17 +8,16 @@ Heat Rating is the percentage of Current Sources that have taken action against an instance. The higher the number of Sources that have silenced and/or suspended an instance, the higher the Heat Rating.*

For Mastodon

- Heat Rating 90%
- Heat Rating 80%
- Heat Rating 70%
- Heat Rating 60%
- Heat Rating 50%
- Heat Rating 40%
- Heat Rating 30%
- Heat Rating 20%
+ @foreach($list as $item) + + Heat Rating: {{$item['heatRating']}}% - Location Count: {{$item['ratingCount']}}
+ + @endforeach
* Heating Ratings are still a work in progress so please review list before using.

+ + @endsection \ No newline at end of file