Added Exports by Heat Rating
Reactivated CSV exports based on Heat Rating, which is the percentage of Current Sources the have taken action, a suspend or a silence, against an instanct. The higher the Heat Rating, the more Sources that have taken actions agaisnt it, so they should be viewed with caution
This commit is contained in:
parent
0d189a4fc3
commit
a15db82697
4 changed files with 71 additions and 21 deletions
|
@ -2,34 +2,56 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Location;
|
||||
use App\Models\Source;
|
||||
|
||||
class ExportController extends Controller
|
||||
{
|
||||
//
|
||||
public function exportCSV()
|
||||
public function exportIndex()
|
||||
{
|
||||
/*
|
||||
$columns = [
|
||||
'id',
|
||||
'product_name',
|
||||
'product_url',
|
||||
'price',
|
||||
'category'
|
||||
];
|
||||
return view('front.exports', [
|
||||
'title' => "Exports"
|
||||
]);
|
||||
}
|
||||
|
||||
$products = [
|
||||
[1, 'product 1', 'https://example.com/product-1', '9.99', 'category 1'],
|
||||
[2, 'product 2', 'https://example.com/product-2', '19.99', 'category 2'],
|
||||
[3, 'product 3', 'https://example.com/product-3', '29.99', 'category 3'],
|
||||
[4, 'product 4', 'https://example.com/product-4', '39.99', 'category 4'],
|
||||
];
|
||||
//
|
||||
public function exportCSV($type, $percent)
|
||||
{
|
||||
$columns = [];
|
||||
$list = [];
|
||||
|
||||
$locations = Location::where("active", true)->get();
|
||||
$sources = Source::where("active", true)->get();
|
||||
if ($type == 'mastodon') {
|
||||
$columns = [
|
||||
'domain',
|
||||
'severity',
|
||||
'public_comment',
|
||||
'reject_media',
|
||||
'reject_reports',
|
||||
'obfuscate',
|
||||
];
|
||||
};
|
||||
|
||||
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') {
|
||||
$comments = str_replace(",", ";", $location->description);
|
||||
array_push($list, [$location->url, $location->rating, $comments, "FALSE", "FALSE", "FALSE"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="products.csv"');
|
||||
header('Content-Disposition: attachment; filename=' . $type . "-" . $percent);
|
||||
|
||||
echo implode(',', $columns) . PHP_EOL;
|
||||
foreach ($products as $product) {
|
||||
echo implode(',', $product) . PHP_EOL;
|
||||
foreach ($list as $item) {
|
||||
echo implode(',', $item) . PHP_EOL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
<a href="/listings/1" title="instance listing" class="nav-links">
|
||||
Listings
|
||||
</a><br />
|
||||
<a href="/exports" title="list exports" class="nav-links">
|
||||
Exports
|
||||
</a><br />
|
||||
@if(Auth::check())
|
||||
<a href="/den" title="den-start" class="nav-links">
|
||||
Den
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
@extends('frame')
|
||||
@section('title', 'The Bad Space|Exports')
|
||||
@section('main-content')
|
||||
@parent
|
||||
<section>
|
||||
<article>
|
||||
<h2>CSV Exports</h2>
|
||||
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.*
|
||||
<h3>For Mastodon</h3>
|
||||
|
||||
<a href="/exports/mastodon/90">Heat Rating 90%</a><br />
|
||||
<a href="/exports/mastodon/80">Heat Rating 80%</a><br />
|
||||
<a href="/exports/mastodon/70">Heat Rating 70%</a><br />
|
||||
<a href="/exports/mastodon/60">Heat Rating 60%</a><br />
|
||||
<a href="/exports/mastodon/50">Heat Rating 50%</a><br />
|
||||
<a href="/exports/mastodon/40">Heat Rating 40%</a><br />
|
||||
<a href="/exports/mastodon/30">Heat Rating 30%</a><br />
|
||||
<a href="/exports/mastodon/20">Heat Rating 20%</a><br />
|
||||
<br />
|
||||
<i>* Heating Ratings are still a work in progress so please review list before using.</i>
|
||||
<br /><br />
|
||||
</article>
|
||||
</section>
|
||||
@endsection
|
|
@ -26,7 +26,8 @@ Route::get("/location/{uuid}", [FrontIndexController::class, 'location']);
|
|||
Route::post("/search", [FrontIndexController::class, 'indexSearch']);
|
||||
|
||||
//exports
|
||||
Route::get("/exports/test", [ExportController::class, 'exportCSV']);
|
||||
Route::get("/exports", [ExportController::class, 'exportIndex']);
|
||||
Route::get("/exports/{type}/{rate}", [ExportController::class, 'exportCSV']);
|
||||
|
||||
//auth
|
||||
Route::get("/login", [AuthController::class, 'showLogin']);
|
||||
|
|
Loading…
Reference in a new issue