@ -72,14 +72,26 @@ class LocationController extends Controller
$index = array_search($item['domain'], array_column($unified, 'url'));
$index = array_search($item['domain'], array_column($unified, 'url'));
if ($index) {
if ($index) {
//if there is a match, update the count
//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 {
} else {
$silence = 0;
$suspend = 0;
if ($item['severity'] == "suspend" || $item['severity'] == "defederate") {
++$silence;
} else {
++$suspend;
}
array_push($unified, [
array_push($unified, [
'name' => $item['domain'],
'name' => $item['domain'],
'url' => $item['domain'],
'url' => $item['domain'],
'rating' => $item['severity'],
'rating' => $item['severity'],
'comment' => $item['comment'],
'comment' => $item['comment'],
'count' => 1,
'block_count' => $suspend,
'silence_count' => $silence,
]);
]);
}
}
}
}
@ -91,14 +103,26 @@ class LocationController extends Controller
$index = array_search($item[0], array_column($unified, 'url'));
$index = array_search($item[0], array_column($unified, 'url'));
if ($index) {
if ($index) {
//if there is a match, update the count
//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 {
} else {
$silence = 0;
$suspend = 0;
if ($item[1] == "suspend" || $item[1] == "defederate") {
++$silence;
} else {
++$suspend;
}
array_push($unified, [
array_push($unified, [
'name' => $item[0],
'name' => $item[0],
'url' => $item[0],
'url' => $item[0],
'rating' => $item[1],
'rating' => $item[1],
'comment' => $item[2],
'comment' => $item[2],
'count' => 1,
'block_count' => $suspend,
'silence_count' => $silence,
]);
]);
}
}
}
}
@ -137,7 +161,8 @@ class LocationController extends Controller
++$duplicates;
++$duplicates;
//update block count for existing item
//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
//replace null with empty array
if ($location->images == null) {
if ($location->images == null) {
@ -150,16 +175,17 @@ class LocationController extends Controller
$images = [];
$images = [];
$rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating'];
$rating = ($item['rating'] == 'defederate') ? 'suspend' : $item['rating'];
$new = Location::create([
$new = Location::create([
'uuid' => Uuid::uuid4(),
'uuid' => Uuid::uuid4(),
'name' => $item['url'],
'name' => $item['url'],
'url' => $item['url'],
'url' => $item['url'],
'description' => ($item['comment'] != null) ? $item['comment'] : "no description",
'description' => ($item['comment'] != null) ? $item['comment'] : "no description",
'active' => true,
'active' => true,
'rating' => $rating,
'rating' => $rating,
'added_by' => 1,
'added_by' => 1,
'tags' => 'poor moderation, hate speech',
'tags' => 'poor moderation, hate speech',
'images' => json_encode($images),
'images' => json_encode($images),
'block_count' => $item['count'],
'block_count' => $item['block_count'],
'silence_count' => $item['silence_count'],
]);
]);
}
}
}
}