mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
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:
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user