@ -72,26 +72,14 @@ 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
if ($item['severity'] == "suspend" || $item['severity'] == "defederate") {
++$unified[$index]['count'];
++$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'],
'block_count' => $suspend,
'count' => 1,
'silence_count' => $silence,
]);
]);
}
}
}
}
@ -103,26 +91,14 @@ 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
if ($item[1] == "suspend" || $item['severity'] == "defederate") {
++$unified[$index]['count'];
++$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],
'block_count' => $suspend,
'count' => 1,
'silence_count' => $silence,
]);
]);
}
}
}
}
@ -161,8 +137,7 @@ class LocationController extends Controller
++$duplicates;
++$duplicates;
//update block count for existing item
//update block count for existing item
$location->block_count = $item['block_count'];
$location->block_count = $item['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) {
@ -175,17 +150,16 @@ 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['block_count'],
'block_count' => $item['count'],
'silence_count' => $item['silence_count'],
]);
]);
}
}
}
}